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.bom org.openhab.core.reactor.bom - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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.bom org.openhab.core.reactor.bom - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.bom.compile @@ -195,7 +195,7 @@ org.jmdns jmdns - 3.5.7 + 3.5.9 compile @@ -203,8 +203,7 @@ org.jupnp org.jupnp - - 2.7.1.OH1 + 3.0.0 compile @@ -364,20 +363,10 @@ - de.jollyday - jollyday - 0.5.10 + de.focus-shift + jollyday-jackson + 0.23.2 compile - - - 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.bom org.openhab.core.reactor.bom - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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.bom org.openhab.core.reactor.bom - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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.bundles org.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.bundles org.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.bundles org.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.core org.openhab.core.reactor - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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.bom org.openhab.core.reactor.bom - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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.bom org.openhab.core.reactor.bom - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.bom.runtime @@ -18,7 +18,7 @@ 2.7.4 3.6.2 - 2.15.2 + 2.16.0 9.4.52.v20230823 2.2.3 8.0.22 @@ -61,6 +61,12 @@ 1.5.0 compile + + org.osgi + org.osgi.service.component.annotations + 1.5.0 + compile + org.apache.felix org.apache.felix.scr @@ -461,7 +467,7 @@ org.jmdns jmdns - 3.5.8 + 3.5.9 compile @@ -469,8 +475,7 @@ org.jupnp org.jupnp - - 2.7.1.OH1 + 3.0.0 compile @@ -942,20 +947,10 @@ - de.jollyday - jollyday - 0.5.10 + de.focus-shift + jollyday-jackson + 0.23.2 compile - - - 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.bom org.openhab.core.reactor.bom - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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.bom org.openhab.core.reactor.bom - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.bom.test @@ -65,7 +65,7 @@ com.jayway.jsonpath json-path - 2.8.0 + 2.9.0 org.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.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.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 outputs = moduleTypeI18nUtil.getLocalizedOutputs(at.getOutputs(), bundle, moduleTypeUID, locale); - ActionType lat = null; + ActionType lat; if (at instanceof CompositeActionType type) { List modules = moduleI18nUtil.getLocalizedModules(type.getChildren(), bundle, moduleTypeUID, ModuleTypeI18nUtil.MODULE_TYPE, locale); @@ -164,7 +164,7 @@ public ModuleTypeI18nServiceImpl(final @Reference ConfigI18nLocalizationService @Nullable Locale locale, @Nullable List lconfigDescriptions, @Nullable String llabel, @Nullable String ldescription) { List inputs = moduleTypeI18nUtil.getLocalizedInputs(ct.getInputs(), bundle, moduleTypeUID, locale); - ConditionType lct = null; + ConditionType lct; if (ct instanceof CompositeConditionType type) { List modules = moduleI18nUtil.getLocalizedModules(type.getChildren(), bundle, moduleTypeUID, ModuleTypeI18nUtil.MODULE_TYPE, locale); @@ -180,7 +180,7 @@ public ModuleTypeI18nServiceImpl(final @Reference ConfigI18nLocalizationService /** * Utility method for localization of TriggerTypes. * - * @param ct is a TriggerType for localization. + * @param tt is a TriggerType for localization. * @param bundle the bundle providing localization resources. * @param moduleTypeUID is a TriggerType uid. * @param locale represents a specific geographical, political, or cultural region. @@ -193,7 +193,7 @@ public ModuleTypeI18nServiceImpl(final @Reference ConfigI18nLocalizationService @Nullable Locale locale, @Nullable List lconfigDescriptions, @Nullable String llabel, @Nullable String ldescription) { List outputs = moduleTypeI18nUtil.getLocalizedOutputs(tt.getOutputs(), bundle, moduleTypeUID, locale); - TriggerType ltt = null; + TriggerType ltt; if (tt instanceof CompositeTriggerType type) { List modules = moduleI18nUtil.getLocalizedModules(type.getChildren(), bundle, moduleTypeUID, ModuleTypeI18nUtil.MODULE_TYPE, locale); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleTypeI18nUtil.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleTypeI18nUtil.java index 0df0fc71243..c041bc105b8 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleTypeI18nUtil.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleTypeI18nUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,8 +25,10 @@ import org.osgi.framework.Bundle; /** - * This class is used as utility for resolving the localized {@link ModuleTypes}s. It automatically infers the key if - * the default text is not a constant with the assistance of {@link TranslationProvider}. + * This class is used as utility for resolving the localized {@link org.openhab.core.automation.type.ModuleType + * ModuleTypes}s. + * It automatically infers the key if the default text is not a constant with the assistance of + * {@link TranslationProvider}. * * @author Ana Dimova - Initial contribution * @author Yordan Mihaylov - updates related to api changes diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/RuleTemplateI18nUtil.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/RuleTemplateI18nUtil.java index 3d73a6a3905..250acc2894f 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/RuleTemplateI18nUtil.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/RuleTemplateI18nUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/ruleengine/WrappedAction.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedAction.java index 063bf0d7ad6..617fa660d1a 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedAction.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedAction.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/ruleengine/WrappedCondition.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedCondition.java index 582fd16120e..6b9efd02f8c 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedCondition.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedCondition.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/ruleengine/WrappedModule.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedModule.java index c4dda6da57e..db8b61e9b5b 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedModule.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedModule.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.automation.internal.ruleengine; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.automation.Module; @@ -23,7 +24,7 @@ * @author Markus Rathgeb - Initial contribution */ @NonNullByDefault -public class WrappedModule { +public class WrappedModule<@NonNull M extends Module, H extends ModuleHandler> { private final M module; private @Nullable H handler; diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedRule.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedRule.java index db6ca936acc..2872df7e097 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedRule.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedRule.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/ruleengine/WrappedTrigger.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedTrigger.java index ab856c2025e..fc50e51cfac 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedTrigger.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/ruleengine/WrappedTrigger.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/template/RuleTemplateRegistry.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/template/RuleTemplateRegistry.java index a7790f3f5ac..942288933da 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/template/RuleTemplateRegistry.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/template/RuleTemplateRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/type/ModuleTypeRegistryImpl.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/type/ModuleTypeRegistryImpl.java index 4444d18d756..d114216cb2b 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/type/ModuleTypeRegistryImpl.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/type/ModuleTypeRegistryImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/provider/ActionModuleKind.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/module/provider/ActionModuleKind.java index afa0e99e495..c35b8d0b5fc 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/module/provider/ActionModuleKind.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/module/provider/ActionModuleKind.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/provider/AnnotationActionModuleTypeHelper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/module/provider/AnnotationActionModuleTypeHelper.java index 153d8b75a8e..1daa68052b2 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/module/provider/AnnotationActionModuleTypeHelper.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/module/provider/AnnotationActionModuleTypeHelper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/provider/ModuleInformation.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/module/provider/ModuleInformation.java index 1f388f36358..2733dad1d72 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/module/provider/ModuleInformation.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/module/provider/ModuleInformation.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/provider/i18n/ModuleTypeI18nService.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/module/provider/i18n/ModuleTypeI18nService.java index 8c7b42d7fc0..d690cbd843a 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/module/provider/i18n/ModuleTypeI18nService.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/module/provider/i18n/ModuleTypeI18nService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/parser/Parser.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/parser/Parser.java index 5c398991dae..ffa89bea097 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/parser/Parser.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/parser/Parser.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,22 +32,22 @@ public interface Parser { * Example : "parser.type" = "parser.module.type"; * It is used as registration property of the corresponding service. */ - static String PARSER_TYPE = "parser.type"; + String PARSER_TYPE = "parser.type"; /** * Defines one of the possible values of property {@link #PARSER_TYPE}. */ - static String PARSER_MODULE_TYPE = "parser.module.type"; + String PARSER_MODULE_TYPE = "parser.module.type"; /** * Defines one of the possible values of property {@link #PARSER_TYPE}. */ - static String PARSER_TEMPLATE = "parser.template"; + String PARSER_TEMPLATE = "parser.template"; /** * Defines one of the possible values of property {@link #PARSER_TYPE}. */ - static String PARSER_RULE = "parser.rule"; + String PARSER_RULE = "parser.rule"; /** * Defines a service registration property used for recognition of which file format is supported by the parser. @@ -55,12 +55,12 @@ public interface Parser { * Example : "format" = "json"; * It is used as registration property of the corresponding service. */ - static String FORMAT = "format"; + String FORMAT = "format"; /** * Defines the possible value of property {@link #FORMAT}. It means that the parser supports json format. */ - static String FORMAT_JSON = "json"; + String FORMAT_JSON = "json"; /** * Loads a file with some particular format and parse it to the corresponding automation objects. diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/parser/ParsingException.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/parser/ParsingException.java index cc878348848..0cdd09a0fc0 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/parser/ParsingException.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/parser/ParsingException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/parser/ParsingNestedException.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/parser/ParsingNestedException.java index 92f7c21bad3..10dd62437be 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/parser/ParsingNestedException.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/parser/ParsingNestedException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/template/RuleTemplate.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/template/RuleTemplate.java index e361674e211..49ab6413ec7 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/template/RuleTemplate.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/template/RuleTemplate.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/template/RuleTemplateProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/template/RuleTemplateProvider.java index a9fb53efecb..1fb35c3e5d4 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/template/RuleTemplateProvider.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/template/RuleTemplateProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/template/Template.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/template/Template.java index f814a246dfa..dab4e19a19f 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/template/Template.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/template/Template.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/template/TemplateProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/template/TemplateProvider.java index b5f39d714a7..97295a6e6c2 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/template/TemplateProvider.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/template/TemplateProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/template/TemplateRegistry.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/template/TemplateRegistry.java index 32a474c284e..467085755a8 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/template/TemplateRegistry.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/template/TemplateRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/thingsupport/AnnotatedThingActionModuleTypeProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/thingsupport/AnnotatedThingActionModuleTypeProvider.java index f1aed13732c..b942a6896a7 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/thingsupport/AnnotatedThingActionModuleTypeProvider.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/thingsupport/AnnotatedThingActionModuleTypeProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/type/ActionType.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/ActionType.java index 578c72f7b1b..47eac6c2f8a 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/ActionType.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/ActionType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/type/CompositeActionType.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/CompositeActionType.java index 94d628030f3..8a500f0525a 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/CompositeActionType.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/CompositeActionType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/type/CompositeConditionType.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/CompositeConditionType.java index fb9ec9ff253..34821b39e42 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/CompositeConditionType.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/CompositeConditionType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/type/CompositeTriggerType.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/CompositeTriggerType.java index ff883763793..014125d04f2 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/CompositeTriggerType.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/CompositeTriggerType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/type/ConditionType.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/ConditionType.java index cb969775849..eb660cda34e 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/ConditionType.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/ConditionType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/type/Input.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/Input.java index dca8bed8caf..273f9343460 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/Input.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/Input.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/type/ModuleType.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/ModuleType.java index 5a411c8bbd4..d740e86a143 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/ModuleType.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/ModuleType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/type/ModuleTypeProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/ModuleTypeProvider.java index 74d2501cada..561c47427c4 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/ModuleTypeProvider.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/ModuleTypeProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/type/ModuleTypeRegistry.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/ModuleTypeRegistry.java index ba59cedbab8..39601f6fba1 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/ModuleTypeRegistry.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/ModuleTypeRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/type/Output.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/Output.java index ce545113dd5..f86477894ff 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/Output.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/Output.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/type/TriggerType.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/TriggerType.java index 74f5264c3ba..7a4b9d38f9a 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/TriggerType.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/type/TriggerType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/util/ActionBuilder.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ActionBuilder.java index 72e84ddfcc9..432803a0849 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ActionBuilder.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ActionBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/util/ConditionBuilder.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ConditionBuilder.java index 3278dddb51f..b18e46ce1c6 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ConditionBuilder.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ConditionBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/util/ConfigurationNormalizer.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ConfigurationNormalizer.java index b548573b86e..4913db4194a 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ConfigurationNormalizer.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ConfigurationNormalizer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/util/ModuleBuilder.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ModuleBuilder.java index 41b264aedd3..c924cb0addd 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ModuleBuilder.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ModuleBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/util/ReferenceResolver.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ReferenceResolver.java index 44ffc8dd261..af21563a4a7 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ReferenceResolver.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ReferenceResolver.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/util/RuleBuilder.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/RuleBuilder.java index e623b486272..092f55eb721 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/RuleBuilder.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/RuleBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/util/TriggerBuilder.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/TriggerBuilder.java index 0e4d38a0c2e..33b4cf1dadd 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/TriggerBuilder.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/TriggerBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/test/java/org/openhab/core/automation/internal/ConnectionValidatorTest.java b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/ConnectionValidatorTest.java index 5cfffbda4b3..888fdb643c7 100644 --- a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/ConnectionValidatorTest.java +++ b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/ConnectionValidatorTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/test/java/org/openhab/core/automation/internal/RulePrefixTest.java b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/RulePrefixTest.java index 440974ca8ca..14c2f43d408 100644 --- a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/RulePrefixTest.java +++ b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/RulePrefixTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/test/java/org/openhab/core/automation/internal/module/factory/EphemerisModuleHandlerFactoryTest.java b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/factory/EphemerisModuleHandlerFactoryTest.java index f277833c29b..1b72cfd3bad 100644 --- a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/factory/EphemerisModuleHandlerFactoryTest.java +++ b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/factory/EphemerisModuleHandlerFactoryTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/test/java/org/openhab/core/automation/internal/module/handler/ChannelEventTriggerHandlerTest.java b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/ChannelEventTriggerHandlerTest.java index 26004142415..df5d8a7b04c 100644 --- a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/ChannelEventTriggerHandlerTest.java +++ b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/ChannelEventTriggerHandlerTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/test/java/org/openhab/core/automation/internal/module/handler/DateTimeTriggerHandlerTest.java b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/DateTimeTriggerHandlerTest.java index 70d2e9b0faf..c78417708fa 100644 --- a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/DateTimeTriggerHandlerTest.java +++ b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/DateTimeTriggerHandlerTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/test/java/org/openhab/core/automation/internal/module/handler/GenericEventTriggerHandlerTest.java b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/GenericEventTriggerHandlerTest.java index 8c86e803383..8b3df8402a1 100644 --- a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/GenericEventTriggerHandlerTest.java +++ b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/GenericEventTriggerHandlerTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/test/java/org/openhab/core/automation/internal/module/handler/GroupCommandTriggerHandlerTest.java b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/GroupCommandTriggerHandlerTest.java new file mode 100644 index 00000000000..61501b9999a --- /dev/null +++ b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/GroupCommandTriggerHandlerTest.java @@ -0,0 +1,72 @@ +/** + * 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.automation.internal.module.handler; + +import static org.mockito.Mockito.when; + +import java.util.Map; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.openhab.core.automation.Trigger; +import org.openhab.core.config.core.Configuration; +import org.openhab.core.items.ItemRegistry; +import org.openhab.core.test.java.JavaTest; +import org.osgi.framework.BundleContext; + +/** + * Test cases for {@link GroupCommandTriggerHandler} + * + * @author Jan N. Klug - Initial contribution + */ +@NonNullByDefault +@ExtendWith(MockitoExtension.class) +class GroupCommandTriggerHandlerTest extends JavaTest { + private @Mock @NonNullByDefault({}) Trigger moduleMock; + private @Mock @NonNullByDefault({}) BundleContext contextMock; + private @Mock @NonNullByDefault({}) ItemRegistry itemRegistryMock; + + @Test + public void testWarningLoggedWhenConfigurationInvalid() { + when(moduleMock.getConfiguration()).thenReturn(new Configuration()); + when(moduleMock.getId()).thenReturn("triggerId"); + setupInterceptedLogger(GroupCommandTriggerHandler.class, LogLevel.WARN); + + GroupCommandTriggerHandler handler = new GroupCommandTriggerHandler(moduleMock, "ruleId", contextMock, + itemRegistryMock); + + stopInterceptedLogger(GroupCommandTriggerHandler.class); + + assertLogMessage(GroupCommandTriggerHandler.class, LogLevel.WARN, + "GroupCommandTrigger triggerId of rule ruleId has no groupName configured and will not work."); + } + + @Test + public void testNoWarningLoggedWhenConfigurationValid() { + when(moduleMock.getConfiguration()) + .thenReturn(new Configuration(Map.of(GroupCommandTriggerHandler.CFG_GROUPNAME, "name"))); + when(moduleMock.getId()).thenReturn("triggerId"); + setupInterceptedLogger(GroupCommandTriggerHandler.class, LogLevel.WARN); + + GroupCommandTriggerHandler handler = new GroupCommandTriggerHandler(moduleMock, "ruleId", contextMock, + itemRegistryMock); + + stopInterceptedLogger(GroupCommandTriggerHandler.class); + + assertLogMessage(GroupCommandTriggerHandler.class, LogLevel.WARN, + "Group 'name' needed for rule 'ruleId' is missing. Trigger 'triggerId' will not work."); + } +} diff --git a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/GroupStateTriggerHandlerTest.java b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/GroupStateTriggerHandlerTest.java new file mode 100644 index 00000000000..83cff0f09b4 --- /dev/null +++ b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/GroupStateTriggerHandlerTest.java @@ -0,0 +1,72 @@ +/** + * 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.automation.internal.module.handler; + +import static org.mockito.Mockito.when; + +import java.util.Map; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.openhab.core.automation.Trigger; +import org.openhab.core.config.core.Configuration; +import org.openhab.core.items.ItemRegistry; +import org.openhab.core.test.java.JavaTest; +import org.osgi.framework.BundleContext; + +/** + * Test cases for {@link GroupStateTriggerHandler} + * + * @author Jan N. Klug - Initial contribution + */ +@NonNullByDefault +@ExtendWith(MockitoExtension.class) +class GroupStateTriggerHandlerTest extends JavaTest { + private @Mock @NonNullByDefault({}) Trigger moduleMock; + private @Mock @NonNullByDefault({}) BundleContext contextMock; + private @Mock @NonNullByDefault({}) ItemRegistry itemRegistryMock; + + @Test + public void testWarningLoggedWhenConfigurationInvalid() { + when(moduleMock.getConfiguration()).thenReturn(new Configuration()); + when(moduleMock.getId()).thenReturn("triggerId"); + setupInterceptedLogger(GroupStateTriggerHandler.class, LogLevel.WARN); + + GroupStateTriggerHandler handler = new GroupStateTriggerHandler(moduleMock, "ruleId", contextMock, + itemRegistryMock); + + stopInterceptedLogger(GroupStateTriggerHandler.class); + + assertLogMessage(GroupStateTriggerHandler.class, LogLevel.WARN, + "GroupStateTrigger triggerId of rule ruleId has no groupName configured and will not work."); + } + + @Test + public void testNoWarningLoggedWhenConfigurationValid() { + when(moduleMock.getConfiguration()) + .thenReturn(new Configuration(Map.of(GroupStateTriggerHandler.CFG_GROUPNAME, "name"))); + when(moduleMock.getId()).thenReturn("triggerId"); + setupInterceptedLogger(GroupStateTriggerHandler.class, LogLevel.WARN); + + GroupStateTriggerHandler handler = new GroupStateTriggerHandler(moduleMock, "ruleId", contextMock, + itemRegistryMock); + + stopInterceptedLogger(GroupStateTriggerHandler.class); + + assertLogMessage(GroupStateTriggerHandler.class, LogLevel.WARN, + "Group 'name' needed for rule 'ruleId' is missing. Trigger 'triggerId' will not work."); + } +} diff --git a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/ItemStateConditionHandlerTest.java b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/ItemStateConditionHandlerTest.java index 44d38c34b5a..1183f4522d3 100644 --- a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/ItemStateConditionHandlerTest.java +++ b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/ItemStateConditionHandlerTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/test/java/org/openhab/core/automation/internal/module/handler/SystemTriggerHandlerTest.java b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/SystemTriggerHandlerTest.java index 8961a7ccdf8..33d94c07f0e 100644 --- a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/SystemTriggerHandlerTest.java +++ b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/handler/SystemTriggerHandlerTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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/test/java/org/openhab/core/automation/internal/module/provider/AnnotationActionModuleTypeProviderTest.java b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/provider/AnnotationActionModuleTypeProviderTest.java index e60912a8568..5505fe94b82 100644 --- a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/provider/AnnotationActionModuleTypeProviderTest.java +++ b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/provider/AnnotationActionModuleTypeProviderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -104,7 +104,7 @@ public void testMultiServiceAnnotationActions() { assertTrue(types.contains(TEST_ACTION_TYPE_ID)); ModuleType mt = prov.getModuleType(TEST_ACTION_TYPE_ID, null); - assertTrue(mt instanceof ActionType); + assertInstanceOf(ActionType.class, mt); ActionType at = (ActionType) mt; @@ -188,7 +188,7 @@ public void testMultiServiceAnnotationActions() { } @ActionScope(name = "binding.test") - private class TestActionProvider implements AnnotatedActions { + private static class TestActionProvider implements AnnotatedActions { @RuleAction(label = ACTION_LABEL, description = ACTION_DESCRIPTION, visibility = Visibility.HIDDEN, tags = { "tag1", "tag2" }) diff --git a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/thingsupport/AnnotatedThingActionModuleTypeProviderTest.java b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/thingsupport/AnnotatedThingActionModuleTypeProviderTest.java index b2f55c422ab..72f72ab9f6a 100644 --- a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/thingsupport/AnnotatedThingActionModuleTypeProviderTest.java +++ b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/thingsupport/AnnotatedThingActionModuleTypeProviderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 testMultiServiceAnnotationActions() { assertTrue(types.contains(TEST_ACTION_TYPE_ID)); ModuleType mt = prov.getModuleType(TEST_ACTION_TYPE_ID, null); - assertTrue(mt instanceof ActionType); + assertInstanceOf(ActionType.class, mt); ActionType at = (ActionType) mt; @@ -142,7 +142,7 @@ public void testMultiServiceAnnotationActions() { assertEquals(ACTION_INPUT1_DEFAULT_VALUE, in.getDefaultValue()); assertEquals(ACTION_INPUT1_DESCRIPTION, in.getDescription()); assertEquals(ACTION_INPUT1_REFERENCE, in.getReference()); - assertEquals(true, in.isRequired()); + assertTrue(in.isRequired()); assertEquals("Item", in.getType()); Set inputTags = in.getTags(); @@ -204,7 +204,7 @@ public void testMultiServiceAnnotationActions() { } @ThingActionsScope(name = "test") - private class TestThingActionProvider implements ThingActions { + private static class TestThingActionProvider implements ThingActions { private @Nullable ThingHandler handler; diff --git a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/util/ReferenceResolverUtilTest.java b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/util/ReferenceResolverUtilTest.java index f060153fc94..033a0acf0f4 100644 --- a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/util/ReferenceResolverUtilTest.java +++ b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/util/ReferenceResolverUtilTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -98,17 +98,17 @@ public void testModuleConfigurationResolving() { Module trigger = ModuleBuilder.createTrigger().withId("id1").withTypeUID("typeUID1") .withConfiguration(new Configuration(MODULE_CONFIGURATION)).build(); ReferenceResolver.updateConfiguration(trigger.getConfiguration(), CONTEXT, logger); - assertEquals(trigger.getConfiguration(), new Configuration(EXPECTED_MODULE_CONFIGURATION)); + assertEquals(new Configuration(EXPECTED_MODULE_CONFIGURATION), trigger.getConfiguration()); // test condition configuration. Module condition = ModuleBuilder.createCondition().withId("id2").withTypeUID("typeUID2") .withConfiguration(new Configuration(MODULE_CONFIGURATION)).build(); ReferenceResolver.updateConfiguration(condition.getConfiguration(), CONTEXT, logger); - assertEquals(condition.getConfiguration(), new Configuration(EXPECTED_MODULE_CONFIGURATION)); + assertEquals(new Configuration(EXPECTED_MODULE_CONFIGURATION), condition.getConfiguration()); // test action configuration. Module action = ModuleBuilder.createAction().withId("id3").withTypeUID("typeUID3") .withConfiguration(new Configuration(MODULE_CONFIGURATION)).build(); ReferenceResolver.updateConfiguration(action.getConfiguration(), CONTEXT, logger); - assertEquals(action.getConfiguration(), new Configuration(EXPECTED_MODULE_CONFIGURATION)); + assertEquals(new Configuration(EXPECTED_MODULE_CONFIGURATION), action.getConfiguration()); } @Test @@ -117,26 +117,26 @@ public void testModuleInputResolving() { Module condition = ModuleBuilder.createCondition().withId("id1").withTypeUID("typeUID1") .withInputs(COMPOSITE_CHILD_MODULE_INPUTS_REFERENCES).build(); Map conditionContext = ReferenceResolver.getCompositeChildContext(condition, CONTEXT); - assertEquals(conditionContext, EXPECTED_COMPOSITE_CHILD_MODULE_CONTEXT); + assertEquals(EXPECTED_COMPOSITE_CHILD_MODULE_CONTEXT, conditionContext); // test Composite child ModuleImpl(action) context Module action = ModuleBuilder.createAction().withId("id2").withTypeUID("typeUID2") .withInputs(COMPOSITE_CHILD_MODULE_INPUTS_REFERENCES).build(); assertEquals(EXPECTED_COMPOSITE_CHILD_MODULE_CONTEXT, conditionContext); Map actionContext = ReferenceResolver.getCompositeChildContext(action, CONTEXT); - assertEquals(actionContext, EXPECTED_COMPOSITE_CHILD_MODULE_CONTEXT); + assertEquals(EXPECTED_COMPOSITE_CHILD_MODULE_CONTEXT, actionContext); } @Test public void testSplitReferenceToTokens() { assertNull(ReferenceResolver.splitReferenceToTokens(null)); - assertTrue(ReferenceResolver.splitReferenceToTokens("").length == 0); + assertEquals(0, ReferenceResolver.splitReferenceToTokens("").length); final String[] referenceTokens = ReferenceResolver .splitReferenceToTokens(".module.array[\".na[m}.\"e\"][1].values1"); - assertTrue("module".equals(referenceTokens[0])); - assertTrue("array".equals(referenceTokens[1])); - assertTrue(".na[m}.\"e".equals(referenceTokens[2])); - assertTrue("1".equals(referenceTokens[3])); - assertTrue("values1".equals(referenceTokens[4])); + assertEquals("module", referenceTokens[0]); + assertEquals("array", referenceTokens[1]); + assertEquals(".na[m}.\"e", referenceTokens[2]); + assertEquals("1", referenceTokens[3]); + assertEquals("values1", referenceTokens[4]); } @Test @@ -250,7 +250,7 @@ public void testGetBeanFieldFromList() { ReferenceResolver.splitReferenceToTokens("[2].value"))); } - public class B1 { + public static class B1 { @SuppressWarnings("unused") private final T value; @@ -259,7 +259,7 @@ public B1(T value) { } } - public class B2 { + public static class B2 { public T value; public B2(T value) { diff --git a/bundles/org.openhab.core.config.core/pom.xml b/bundles/org.openhab.core.config.core/pom.xml index a04f3a71a66..8221b4b6b68 100644 --- a/bundles/org.openhab.core.config.core/pom.xml +++ b/bundles/org.openhab.core.config.core/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.config.core diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescription.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescription.java index e57cf013630..4ef78d02761 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescription.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescription.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionAliasProvider.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionAliasProvider.java index 21c69424375..fae4f47a226 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionAliasProvider.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionAliasProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionBuilder.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionBuilder.java index cf165efe668..8d09401be6a 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionBuilder.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionParameter.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionParameter.java index 464636e2264..8889aeaee18 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionParameter.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionParameter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionParameterBuilder.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionParameterBuilder.java index 6a4812b7744..bb91ecd2289 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionParameterBuilder.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionParameterBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionParameterGroup.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionParameterGroup.java index 52e46762749..64459cb85e2 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionParameterGroup.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionParameterGroup.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionParameterGroupBuilder.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionParameterGroupBuilder.java index 920531a99b3..5bfa5d16647 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionParameterGroupBuilder.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionParameterGroupBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -94,7 +94,6 @@ public ConfigDescriptionParameterGroupBuilder withDescription(@Nullable String d * @return the desired result */ public ConfigDescriptionParameterGroup build() throws IllegalArgumentException { - return new ConfigDescriptionParameterGroup(name, context, advanced != null ? advanced : false, label, - description); + return new ConfigDescriptionParameterGroup(name, context, advanced != null && advanced, label, description); } } diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionProvider.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionProvider.java index 17721fab4b5..03892d67627 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionProvider.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionRegistry.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionRegistry.java index c8dbd8a7361..671f5edaf3c 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionRegistry.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigDescriptionRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -126,12 +126,7 @@ public Collection getConfigDescriptions(@Nullable Locale loca } // Now convert the map into the collection - Collection configDescriptions = new ArrayList<>(configMap.size()); - for (ConfigDescription configDescription : configMap.values()) { - configDescriptions.add(configDescription); - } - - return Collections.unmodifiableCollection(configDescriptions); + return Collections.unmodifiableCollection(new ArrayList<>(configMap.values())); } /** @@ -245,10 +240,8 @@ private boolean fillFromProviders(URI uri, @Nullable Locale locale, List aliases, ConfigDescriptionParameter parameter, @Nullable Locale locale) { - List options = new ArrayList<>(); - // Add all the existing options that may be provided by the initial config description provider - options.addAll(parameter.getOptions()); + List options = new ArrayList<>(parameter.getOptions()); boolean found = fillFromProviders(uri, parameter, locale, options); diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigOptionProvider.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigOptionProvider.java index 778e16fcebb..e3361206a11 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigOptionProvider.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigOptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/ConfigParser.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigParser.java index b59980bf193..9e3797fde5a 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigParser.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigParser.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -41,7 +41,7 @@ */ @NonNullByDefault public final class ConfigParser { - private static final transient Logger LOGGER = LoggerFactory.getLogger(ConfigParser.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ConfigParser.class); private static final Map> WRAPPER_CLASSES_MAP = Map.of(// "float", Float.class, // "double", Double.class, // diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigUtil.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigUtil.java index ad8a4aa5d9e..2b9ea09cf15 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigUtil.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/ConfigurableService.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigurableService.java index 362586c4f89..38f297ab9bc 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigurableService.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigurableService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/ConfigurableServiceUtil.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigurableServiceUtil.java index afd7b059dd8..3f4d87c6f2f 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigurableServiceUtil.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigurableServiceUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -91,6 +91,6 @@ private static String resolveString(Function propertyR private static boolean resolveBoolean(Function propertyResolver, String key) { Boolean value = (Boolean) propertyResolver.apply(key); - return value == null ? false : value.booleanValue(); + return value != null && value.booleanValue(); } } diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/Configuration.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/Configuration.java index 07a4ddd7daf..1356b0913ed 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/Configuration.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/Configuration.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +12,7 @@ */ package org.openhab.core.config.core; -import static java.util.Collections.*; +import static java.util.Collections.synchronizedMap; import static org.openhab.core.config.core.ConfigUtil.normalizeTypes; import java.util.ArrayList; diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigurationDeserializer.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigurationDeserializer.java index e3ff801f52b..63570631cef 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigurationDeserializer.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigurationDeserializer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/ConfigurationSerializer.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigurationSerializer.java index fbee48d0c62..8a4851dc1ae 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigurationSerializer.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ConfigurationSerializer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/CurrencyServiceConfigOptionProvider.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/CurrencyServiceConfigOptionProvider.java new file mode 100644 index 00000000000..5e4620bdb5b --- /dev/null +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/CurrencyServiceConfigOptionProvider.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.config.core; + +import java.net.URI; +import java.util.Collection; +import java.util.List; +import java.util.Locale; +import java.util.concurrent.CopyOnWriteArrayList; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.core.library.unit.CurrencyProvider; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.component.annotations.ReferenceCardinality; +import org.osgi.service.component.annotations.ReferencePolicy; + +/** + * The {@link CurrencyServiceConfigOptionProvider} is an implementation of {@link ConfigOptionProvider} for the + * available currency providers. + * + * @author Jan N. Klug - Initial contribution + */ +@Component(service = ConfigOptionProvider.class) +@NonNullByDefault +public class CurrencyServiceConfigOptionProvider implements ConfigOptionProvider { + + private final List currencyProviders = new CopyOnWriteArrayList<>(); + + @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) + public void addCurrencyProvider(CurrencyProvider currencyProvider) { + currencyProviders.add(currencyProvider); + } + + public void removeCurrencyProvider(CurrencyProvider currencyProvider) { + currencyProviders.remove(currencyProvider); + } + + @Override + public @Nullable Collection getParameterOptions(URI uri, String param, @Nullable String context, + @Nullable Locale locale) { + if ("system:units".equals(uri.toString()) && "currencyProvider".equals(param)) { + return currencyProviders.stream().map(this::mapProvider).toList(); + } + return null; + } + + private ParameterOption mapProvider(CurrencyProvider currencyProvider) { + String providerName = currencyProvider.getName(); + int lastDot = providerName.lastIndexOf("."); + String providerDescription = lastDot > -1 ? providerName.substring(lastDot + 1) : providerName; + return new ParameterOption(providerName, providerDescription); + } +} diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/FilterCriteria.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/FilterCriteria.java index c07ed543360..194620588d0 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/FilterCriteria.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/FilterCriteria.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/OrderingMapSerializer.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/OrderingMapSerializer.java index c6a74a4d5dd..28bd089d024 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/OrderingMapSerializer.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/OrderingMapSerializer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/OrderingSetSerializer.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/OrderingSetSerializer.java index 2a154dcd20b..abbfbf35eef 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/OrderingSetSerializer.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/OrderingSetSerializer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/ParameterOption.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ParameterOption.java index 32ecffa8134..6c0b1d82049 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ParameterOption.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/ParameterOption.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/dto/ConfigDescriptionDTO.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/ConfigDescriptionDTO.java index 8c046dd6191..1a046c43301 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/ConfigDescriptionDTO.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/ConfigDescriptionDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/dto/ConfigDescriptionDTOMapper.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/ConfigDescriptionDTOMapper.java index 12bdf73d685..0348d3c8f85 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/ConfigDescriptionDTOMapper.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/ConfigDescriptionDTOMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/dto/ConfigDescriptionParameterDTO.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/ConfigDescriptionParameterDTO.java index c91a0a59fc7..afdd62ecd87 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/ConfigDescriptionParameterDTO.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/ConfigDescriptionParameterDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/dto/ConfigDescriptionParameterGroupDTO.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/ConfigDescriptionParameterGroupDTO.java index a870f041e86..8d90b50a3db 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/ConfigDescriptionParameterGroupDTO.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/ConfigDescriptionParameterGroupDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/dto/FilterCriteriaDTO.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/FilterCriteriaDTO.java index 4aa30068e67..de8a79104a3 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/FilterCriteriaDTO.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/FilterCriteriaDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/dto/ParameterOptionDTO.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/ParameterOptionDTO.java index c9f17256afa..2b9602ad8c1 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/ParameterOptionDTO.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/dto/ParameterOptionDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/i18n/ConfigI18nLocalizationService.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/i18n/ConfigI18nLocalizationService.java index e5485372603..07151e6db66 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/i18n/ConfigI18nLocalizationService.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/i18n/ConfigI18nLocalizationService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/i18n/ConfigDescriptionGroupI18nUtil.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/i18n/ConfigDescriptionGroupI18nUtil.java index 726b0cf2cc4..8eabb1d6259 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/i18n/ConfigDescriptionGroupI18nUtil.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/i18n/ConfigDescriptionGroupI18nUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/i18n/ConfigDescriptionI18nUtil.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/i18n/ConfigDescriptionI18nUtil.java index 3afa3bbd09a..ea72276dd42 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/i18n/ConfigDescriptionI18nUtil.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/i18n/ConfigDescriptionI18nUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/i18n/I18nConfigOptionsProvider.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/i18n/I18nConfigOptionsProvider.java index 13df696aa4f..3b866b0d6f0 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/i18n/I18nConfigOptionsProvider.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/i18n/I18nConfigOptionsProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 @@ import org.osgi.service.component.annotations.Component; /** - * {@link ConfigOptionProvider} that provides a list of + * A {@link ConfigOptionProvider} that provides a list of config options for the i18n service * * @author Simon Kaufmann - Initial contribution * @author Erdoan Hadzhiyusein - Added time zone @@ -78,8 +78,8 @@ public class I18nConfigOptionsProvider implements ConfigOptionProvider { } private Collection processTimeZoneParam() { - Comparator byOffset = (t1, t2) -> t1.getRawOffset() - t2.getRawOffset(); - Comparator byID = (t1, t2) -> t1.getID().compareTo(t2.getID()); + Comparator byOffset = Comparator.comparingInt(TimeZone::getRawOffset); + Comparator byID = Comparator.comparing(TimeZone::getID); return ZoneId.getAvailableZoneIds().stream().map(TimeZone::getTimeZone).sorted(byOffset.thenComparing(byID)) .map(tz -> new ParameterOption(tz.getID(), getTimeZoneRepresentation(tz))).toList(); } @@ -105,7 +105,7 @@ private Collection getAvailable(@Nullable Locale locale, .map(mapFunction) // .distinct() // .filter(po -> !po.getValue().isEmpty()) // - .sorted(Comparator.comparing(a -> a.getLabel())) // + .sorted(Comparator.comparing(ParameterOption::getLabel)) // .toList(); } } diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/metadata/MetadataConfigDescriptionProviderImpl.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/metadata/MetadataConfigDescriptionProviderImpl.java index 036aa187c3e..7b75073b1df 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/metadata/MetadataConfigDescriptionProviderImpl.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/metadata/MetadataConfigDescriptionProviderImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,9 +71,7 @@ public class MetadataConfigDescriptionProviderImpl implements ConfigDescriptionP @Override public Collection getConfigDescriptions(@Nullable Locale locale) { - List ret = new LinkedList<>(); - ret.addAll(getValueConfigDescriptions(locale)); - return ret; + return new LinkedList<>(getValueConfigDescriptions(locale)); } @Override diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/net/NetworkConfigOptionProvider.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/net/NetworkConfigOptionProvider.java index 72556d5b594..1e2760bf460 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/net/NetworkConfigOptionProvider.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/net/NetworkConfigOptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,9 +13,13 @@ package org.openhab.core.config.core.internal.net; import java.net.Inet4Address; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; import java.net.URI; import java.util.ArrayList; import java.util.Collection; +import java.util.Enumeration; import java.util.List; import java.util.Locale; import java.util.stream.Stream; @@ -39,25 +43,55 @@ public class NetworkConfigOptionProvider implements ConfigOptionProvider { static final URI CONFIG_URI = URI.create("system:network"); static final String PARAM_PRIMARY_ADDRESS = "primaryAddress"; static final String PARAM_BROADCAST_ADDRESS = "broadcastAddress"; + static final String NETWORK_INTERFACE = "network-interface"; @Override public @Nullable Collection getParameterOptions(URI uri, String param, @Nullable String context, @Nullable Locale locale) { - if (!CONFIG_URI.equals(uri)) { + if (CONFIG_URI.equals(uri)) { + switch (param) { + case PARAM_PRIMARY_ADDRESS: + Stream ipv4Addresses = NetUtil.getAllInterfaceAddresses().stream() + .filter(a -> a.getAddress() instanceof Inet4Address); + return ipv4Addresses.map(a -> new ParameterOption(a.toString(), a.toString())).toList(); + case PARAM_BROADCAST_ADDRESS: + List broadcastAddrList = new ArrayList<>(NetUtil.getAllBroadcastAddresses()); + broadcastAddrList.add("255.255.255.255"); + return broadcastAddrList.stream().distinct().map(a -> new ParameterOption(a, a)).toList(); + default: + return null; + } + } else if (NETWORK_INTERFACE.equals(context)) { + try { + List options = new ArrayList<>(); + Enumeration networkInterfaces = NetworkInterface.getNetworkInterfaces(); + while (networkInterfaces.hasMoreElements()) { + NetworkInterface networkInterface = networkInterfaces.nextElement(); + options.add(new ParameterOption(networkInterface.getName(), + getNetworkInterfaceLabel(networkInterface))); + } + return options; + } catch (SocketException e) { + return null; + } + } else { return null; } + } - switch (param) { - case PARAM_PRIMARY_ADDRESS: - Stream ipv4Addresses = NetUtil.getAllInterfaceAddresses().stream() - .filter(a -> a.getAddress() instanceof Inet4Address); - return ipv4Addresses.map(a -> new ParameterOption(a.toString(), a.toString())).toList(); - case PARAM_BROADCAST_ADDRESS: - List broadcastAddrList = new ArrayList<>(NetUtil.getAllBroadcastAddresses()); - broadcastAddrList.add("255.255.255.255"); - return broadcastAddrList.stream().distinct().map(a -> new ParameterOption(a, a)).toList(); - default: - return null; + private String getNetworkInterfaceLabel(NetworkInterface networkInterface) { + Enumeration inetAddresses = networkInterface.getInetAddresses(); + String hostName = null; + while (inetAddresses.hasMoreElements()) { + InetAddress inetAddress = inetAddresses.nextElement(); + if (inetAddress instanceof Inet4Address) { + hostName = inetAddress.getHostName(); + break; + } else if (hostName == null) { + hostName = inetAddress.getHostName(); + } } + return hostName == null ? networkInterface.getName() + : String.format("%s (%s)", networkInterface.getName(), hostName); } } diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/AbstractNormalizer.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/AbstractNormalizer.java index 92bf83c5742..97061fb6352 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/AbstractNormalizer.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/AbstractNormalizer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/BooleanNormalizer.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/BooleanNormalizer.java index e72357a9eb3..118479c6a23 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/BooleanNormalizer.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/BooleanNormalizer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/DecimalNormalizer.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/DecimalNormalizer.java index 58470da0b58..8c3498f1374 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/DecimalNormalizer.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/DecimalNormalizer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/IntNormalizer.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/IntNormalizer.java index 28a34243dde..aafa36b609b 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/IntNormalizer.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/IntNormalizer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/ListNormalizer.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/ListNormalizer.java index ce19336fb32..386e90399af 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/ListNormalizer.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/ListNormalizer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/Normalizer.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/Normalizer.java index 593b8a96e6b..ebd4649788a 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/Normalizer.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/Normalizer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/NormalizerFactory.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/NormalizerFactory.java index b7d921ee7b3..c7a905d297b 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/NormalizerFactory.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/NormalizerFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/TextNormalizer.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/TextNormalizer.java index 880ba4b8f9f..410a776b130 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/TextNormalizer.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/normalization/TextNormalizer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionParameterValidator.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionParameterValidator.java index 3e440cac9a1..703d6f2d07e 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionParameterValidator.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionParameterValidator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionParameterValidatorFactory.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionParameterValidatorFactory.java index 31b6e4eafc1..e5f1b5107ed 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionParameterValidatorFactory.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionParameterValidatorFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionValidatorImpl.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionValidatorImpl.java index 1fa4eb43f32..5ec97ccb17f 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionValidatorImpl.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionValidatorImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.util.Collection; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Objects; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -101,35 +102,33 @@ public void validate(Map configurationParameters, URI configDesc Collection configDescriptionValidationMessages = new ArrayList<>(); - for (String key : map.keySet()) { - ConfigDescriptionParameter configDescriptionParameter = map.get(key); - if (configDescriptionParameter != null) { - // If the parameter supports multiple selection, then it may be provided as an array - if (configDescriptionParameter.isMultiple() && configurationParameters.get(key) instanceof List) { - List values = (List) configurationParameters.get(key); - // check if multipleLimit is obeyed - Integer multipleLimit = configDescriptionParameter.getMultipleLimit(); - if (multipleLimit != null && values.size() > multipleLimit) { - MessageKey messageKey = MessageKey.MULTIPLE_LIMIT_VIOLATED; - ConfigValidationMessage message = new ConfigValidationMessage( - configDescriptionParameter.getName(), messageKey.defaultMessage, messageKey.key, - multipleLimit, values.size()); - configDescriptionValidationMessages.add(message); - } - // Perform validation on each value in the list separately - for (Object value : values) { - ConfigValidationMessage message = validateParameter(configDescriptionParameter, value); - if (message != null) { - configDescriptionValidationMessages.add(message); - } - } - } else { - ConfigValidationMessage message = validateParameter(configDescriptionParameter, - configurationParameters.get(key)); + for (Entry entry : map.entrySet()) { + String key = entry.getKey(); + ConfigDescriptionParameter configDescriptionParameter = entry.getValue(); + // If the parameter supports multiple selection, then it may be provided as an array + if (configDescriptionParameter.isMultiple() && configurationParameters.get(key) instanceof List) { + List values = (List) configurationParameters.get(key); + // check if multipleLimit is obeyed + Integer multipleLimit = configDescriptionParameter.getMultipleLimit(); + if (multipleLimit != null && values.size() > multipleLimit) { + MessageKey messageKey = MessageKey.MULTIPLE_LIMIT_VIOLATED; + ConfigValidationMessage message = new ConfigValidationMessage(configDescriptionParameter.getName(), + messageKey.defaultMessage, messageKey.key, multipleLimit, values.size()); + configDescriptionValidationMessages.add(message); + } + // Perform validation on each value in the list separately + for (Object value : values) { + ConfigValidationMessage message = validateParameter(configDescriptionParameter, value); if (message != null) { configDescriptionValidationMessages.add(message); } } + } else { + ConfigValidationMessage message = validateParameter(configDescriptionParameter, + configurationParameters.get(key)); + if (message != null) { + configDescriptionValidationMessages.add(message); + } } } diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/MessageKey.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/MessageKey.java index eb36104df9b..6cac1e9b57d 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/MessageKey.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/MessageKey.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/validation/MinMaxValidator.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/MinMaxValidator.java index 4de3a45ba32..67379386d19 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/MinMaxValidator.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/MinMaxValidator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/validation/OptionsValidator.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/OptionsValidator.java index db2c7d2efa9..b3cd65732da 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/OptionsValidator.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/OptionsValidator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.config.core.ConfigDescriptionParameter; +import org.openhab.core.config.core.ParameterOption; import org.openhab.core.config.core.validation.ConfigValidationMessage; /** @@ -42,7 +43,8 @@ final class OptionsValidator implements ConfigDescriptionParameterValidator { invalid = param.getOptions().stream().map(o -> new BigDecimal(o.getValue())) .noneMatch(v -> v.compareTo(bdValue) == 0); } else { - invalid = param.getOptions().stream().map(o -> o.getValue()).noneMatch(v -> v.equals(value.toString())); + invalid = param.getOptions().stream().map(ParameterOption::getValue) + .noneMatch(v -> v.equals(value.toString())); } if (invalid) { diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/PatternValidator.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/PatternValidator.java index 7d580643f0d..a0b288661ec 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/PatternValidator.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/PatternValidator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/validation/RequiredValidator.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/RequiredValidator.java index 18f492f3f89..c5e6e016583 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/RequiredValidator.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/RequiredValidator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/validation/TypeIntrospections.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/TypeIntrospections.java index 407d8862bc5..ce8267adda2 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/TypeIntrospections.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/TypeIntrospections.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/internal/validation/TypeValidator.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/TypeValidator.java index a33323c4c4a..fc51ce2c985 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/TypeValidator.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/internal/validation/TypeValidator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/metadata/MetadataConfigDescriptionProvider.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/metadata/MetadataConfigDescriptionProvider.java index 6e740d052a5..0f3064e7b57 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/metadata/MetadataConfigDescriptionProvider.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/metadata/MetadataConfigDescriptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusCallback.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusCallback.java index f295ffc2640..d2b9b467727 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusCallback.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusCallback.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusInfo.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusInfo.java index e040e359f7f..7e60e5c13fb 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusInfo.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusInfo.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusMessage.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusMessage.java index b5e7eea842b..9d470031fbc 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusMessage.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusMessage.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -66,7 +66,7 @@ public enum Type { * The type for a pending message. It should be used if the transmission of the configuration parameter to the * entity is pending. */ - PENDING; + PENDING } /** The name of the configuration parameter. */ diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusProvider.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusProvider.java index 5b83b39f41a..0acabe2b564 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusProvider.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusService.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusService.java index e4a6b635209..b2ffc7e76dc 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusService.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusSource.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusSource.java index b4c37681761..31d3a894d01 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusSource.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/ConfigStatusSource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/status/events/ConfigStatusEventFactory.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/events/ConfigStatusEventFactory.java index 19b04977167..c47ba256300 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/events/ConfigStatusEventFactory.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/events/ConfigStatusEventFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/status/events/ConfigStatusInfoEvent.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/events/ConfigStatusInfoEvent.java index 45cd50b2cc1..6886992798c 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/events/ConfigStatusInfoEvent.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/status/events/ConfigStatusInfoEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/validation/ConfigDescriptionValidator.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/validation/ConfigDescriptionValidator.java index eccb042c3b4..4ebd26f289c 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/validation/ConfigDescriptionValidator.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/validation/ConfigDescriptionValidator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/validation/ConfigValidationException.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/validation/ConfigValidationException.java index 6f271ceab6e..9d3fd848f91 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/validation/ConfigValidationException.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/validation/ConfigValidationException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/validation/ConfigValidationMessage.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/validation/ConfigValidationMessage.java index eaeca82b75f..6e524a36421 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/validation/ConfigValidationMessage.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/validation/ConfigValidationMessage.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/AbstractXmlBasedProvider.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/AbstractXmlBasedProvider.java index b54f337ccb3..0edc22656e9 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/AbstractXmlBasedProvider.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/AbstractXmlBasedProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,6 +19,7 @@ import java.util.Locale; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; @@ -78,10 +79,8 @@ public final synchronized void addAll(Bundle bundle, Collection object if (objectList.isEmpty()) { return; } - List objects = acquireObjects(bundle); - if (objects == null) { - return; - } + List objects = Objects + .requireNonNull(bundleObjectMap.computeIfAbsent(bundle, k -> new CopyOnWriteArrayList<>())); objects.addAll(objectList); for (T_OBJECT object : objectList) { // just make sure no old entry remains in the cache @@ -89,15 +88,6 @@ public final synchronized void addAll(Bundle bundle, Collection object } } - private @Nullable List acquireObjects(Bundle bundle) { - List objects = bundleObjectMap.get(bundle); - if (objects == null) { - objects = new CopyOnWriteArrayList<>(); - bundleObjectMap.put(bundle, objects); - } - return objects; - } - /** * Gets the object with the given key. * diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/AbstractXmlConfigDescriptionProvider.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/AbstractXmlConfigDescriptionProvider.java index 73e49561bf5..f0f39f55332 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/AbstractXmlConfigDescriptionProvider.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/AbstractXmlConfigDescriptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/ConfigDescriptionConverter.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/ConfigDescriptionConverter.java index a3a30be56f9..ad206c85444 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/ConfigDescriptionConverter.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/ConfigDescriptionConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -65,7 +65,7 @@ public ConfigDescriptionConverter() { uriText = (String) context.get("config-description.uri"); } - URI uri = null; + URI uri; if (uriText == null) { throw new ConversionException("No URI provided"); } diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/ConfigDescriptionParameterConverter.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/ConfigDescriptionParameterConverter.java index 7574db2d7f2..b702332144e 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/ConfigDescriptionParameterConverter.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/ConfigDescriptionParameterConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,12 +88,12 @@ public ConfigDescriptionParameterConverter() { } private Boolean falseIfNull(@Nullable Boolean b) { - return b != null ? b : false; + return b != null && b; } @Override public @Nullable Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { - ConfigDescriptionParameter configDescriptionParam = null; + ConfigDescriptionParameter configDescriptionParam; // read attributes Map attributes = this.attributeMapValidator.readValidatedAttributes(reader); diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/ConfigDescriptionParameterGroupConverter.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/ConfigDescriptionParameterGroupConverter.java index efaf0e221c5..177ac021095 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/ConfigDescriptionParameterGroupConverter.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/ConfigDescriptionParameterGroupConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/ConfigXmlConfigDescriptionProvider.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/ConfigXmlConfigDescriptionProvider.java index dacef5ddb07..107bcffbd00 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/ConfigXmlConfigDescriptionProvider.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/ConfigXmlConfigDescriptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/FilterCriteriaConverter.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/FilterCriteriaConverter.java index 86ca1ea1ac3..33f55cbf773 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/FilterCriteriaConverter.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/FilterCriteriaConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/internal/ConfigDescriptionReader.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/internal/ConfigDescriptionReader.java index 7b70e5a05b0..328342945b2 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/internal/ConfigDescriptionReader.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/internal/ConfigDescriptionReader.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/internal/ConfigDescriptionXmlProvider.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/internal/ConfigDescriptionXmlProvider.java index 8d6578da166..e75b8f8e6a0 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/internal/ConfigDescriptionXmlProvider.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/internal/ConfigDescriptionXmlProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -30,8 +30,6 @@ * is itself registered as {@link ConfigDescriptionProvider} service at the OSGi service registry. * * @author Michael Grammling - Initial contribution - * - * @see ConfigDescriptionXmlProviderFactory */ @NonNullByDefault public class ConfigDescriptionXmlProvider implements XmlDocumentProvider> { diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/osgi/XmlDocumentBundleTracker.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/osgi/XmlDocumentBundleTracker.java index a7b79814856..94d5b85a8d5 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/osgi/XmlDocumentBundleTracker.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/osgi/XmlDocumentBundleTracker.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.net.URL; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Enumeration; import java.util.HashMap; @@ -89,11 +88,11 @@ private static T withLock(final Lock lock, final Supplier supplier) { * create, close, open * This can be handled correctly using three states and checking the transition. */ - private static enum OpenState { + private enum OpenState { CREATED, OPENED, CLOSED - }; + } public static final String THREAD_POOL_NAME = "file-processing"; @@ -151,7 +150,7 @@ private Set getRelevantBundles() { if (bundleTracker == null || bundleTracker.getBundles() == null) { return Set.of(); } - return (Set) Arrays.stream(bundleTracker.getBundles()).collect(Collectors.toSet()); + return Set.of(bundleTracker.getBundles()); } @Override diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/osgi/XmlDocumentProvider.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/osgi/XmlDocumentProvider.java index e133be3deb8..263e8090ed9 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/osgi/XmlDocumentProvider.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/osgi/XmlDocumentProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/osgi/XmlDocumentProviderFactory.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/osgi/XmlDocumentProviderFactory.java index 9fe90f6c015..0ca6d95a9e7 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/osgi/XmlDocumentProviderFactory.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/osgi/XmlDocumentProviderFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/util/ConverterAttributeMapValidator.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/ConverterAttributeMapValidator.java index fc886cd57b3..a093e662659 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/ConverterAttributeMapValidator.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/ConverterAttributeMapValidator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/util/ConverterValueMap.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/ConverterValueMap.java index 39dc4f9a02a..fa0c69478b7 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/ConverterValueMap.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/ConverterValueMap.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -62,7 +62,7 @@ public ConverterValueMap(HierarchicalStreamReader reader, int numberOfValues, Un throws ConversionException { this.reader = reader; this.context = context; - this.valueMap = readValueMap(this.reader, numberOfValues >= -1 ? numberOfValues : -1, this.context); + this.valueMap = readValueMap(this.reader, Math.max(numberOfValues, -1), this.context); } /** diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/GenericUnmarshaller.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/GenericUnmarshaller.java index cfe2c8061e2..37e0d7c6e48 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/GenericUnmarshaller.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/GenericUnmarshaller.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeAttributes.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeAttributes.java index 79686383183..6347acf65a8 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeAttributes.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeAttributes.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeAttributesConverter.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeAttributesConverter.java index 2f5363830b9..a84641a1eae 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeAttributesConverter.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeAttributesConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeIterator.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeIterator.java index fdee71def99..825d0a0c844 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeIterator.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeIterator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeList.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeList.java index f77eb549b5f..037fcba9f82 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeList.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeList.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeListConverter.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeListConverter.java index f528cb27a43..9e9e6c40780 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeListConverter.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeListConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeName.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeName.java index 9c0c628a495..5df6d909efc 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeName.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeName.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeValue.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeValue.java index 042254d6f82..94c32a696f4 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeValue.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeValue.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeValueConverter.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeValueConverter.java index 121e811053b..40ad36124cd 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeValueConverter.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/NodeValueConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/main/java/org/openhab/core/config/core/xml/util/XmlDocumentReader.java b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/XmlDocumentReader.java index caa8bfd343a..ed0eb938069 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/XmlDocumentReader.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/openhab/core/config/core/xml/util/XmlDocumentReader.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,6 +19,7 @@ import org.eclipse.jdt.annotation.Nullable; import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.XStreamException; import com.thoughtworks.xstream.converters.ConversionException; import com.thoughtworks.xstream.converters.Converter; import com.thoughtworks.xstream.io.xml.StaxDriver; @@ -70,7 +71,7 @@ protected void setClassLoader(ClassLoader classLoader) { * * @param xstream the XStream object to be configured * - * @see https://x-stream.github.io/security.html + * @see XStream - Security Aspects */ protected void configureSecurity(XStream xstream) { xstream.allowTypesByWildcard(DEFAULT_ALLOWED_TYPES_WILDCARD); @@ -104,4 +105,18 @@ protected void configureSecurity(XStream xstream) { public @Nullable T readFromXML(URL xmlURL) throws ConversionException { return (@Nullable T) xstream.fromXML(xmlURL); } + + /** + * Reads the XML document containing a specific XML tag from the specified xml string and converts it to the + * according object. + * + * @param xml a string containing the XML document to be read. + * @return the conversion result object (could be null). + * @throws XStreamException if the object cannot be deserialized. + * @throws ConversionException if the specified document contains invalid content + */ + @SuppressWarnings("unchecked") + public @Nullable T readFromXML(String xml) throws ConversionException { + return (@Nullable T) xstream.fromXML(xml); + } } diff --git a/bundles/org.openhab.core.config.core/src/test/java/com/acme/Product.java b/bundles/org.openhab.core.config.core/src/test/java/com/acme/Product.java index 432af757581..e73c68bf07a 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/com/acme/Product.java +++ b/bundles/org.openhab.core.config.core/src/test/java/com/acme/Product.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/test/java/org/openhab/core/config/core/ConfigDescriptionBuilderTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigDescriptionBuilderTest.java index 1ebfff4dc5b..1c23e138c9e 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigDescriptionBuilderTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigDescriptionBuilderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/test/java/org/openhab/core/config/core/ConfigDescriptionParameterBuilderTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigDescriptionParameterBuilderTest.java index 903b25ae40d..25ef8d6f188 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigDescriptionParameterBuilderTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigDescriptionParameterBuilderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/test/java/org/openhab/core/config/core/ConfigDescriptionParameterGroupBuilderTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigDescriptionParameterGroupBuilderTest.java index 2ff3fe0ea34..598b83c71de 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigDescriptionParameterGroupBuilderTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigDescriptionParameterGroupBuilderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/test/java/org/openhab/core/config/core/ConfigDescriptionRegistryTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigDescriptionRegistryTest.java index f1292a9f0ef..e0e08902fe1 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigDescriptionRegistryTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigDescriptionRegistryTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/test/java/org/openhab/core/config/core/ConfigParserTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigParserTest.java index 45008403e4d..47dbae989d8 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigParserTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigParserTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/test/java/org/openhab/core/config/core/ConfigUtilTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigUtilTest.java index 393def39003..9c8a09455ca 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigUtilTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigUtilTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/test/java/org/openhab/core/config/core/ConfigurableServiceUtilTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigurableServiceUtilTest.java index 1eab614ae7c..6e19acb6754 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigurableServiceUtilTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigurableServiceUtilTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,8 +43,7 @@ public void asConfigurableServiceDefinedProperties() { properties.put(SERVICE_PROPERTY_FACTORY_SERVICE, factory); properties.put(SERVICE_PROPERTY_LABEL, label); - ConfigurableService configurableService = ConfigurableServiceUtil - .asConfigurableService((key) -> properties.get(key)); + ConfigurableService configurableService = ConfigurableServiceUtil.asConfigurableService(properties::get); assertThat(configurableService.annotationType(), is(ConfigurableService.class)); assertThat(configurableService.category(), is(category)); @@ -57,8 +56,7 @@ public void asConfigurableServiceDefinedProperties() { public void asConfigurableServiceUndefinedProperties() { Properties properties = new Properties(); - ConfigurableService configurableService = ConfigurableServiceUtil - .asConfigurableService((key) -> properties.get(key)); + ConfigurableService configurableService = ConfigurableServiceUtil.asConfigurableService(properties::get); assertThat(configurableService.annotationType(), is(ConfigurableService.class)); assertThat(configurableService.category(), is(emptyString())); diff --git a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigurationTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigurationTest.java index 2a38f3cb23e..c7b00218f82 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigurationTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/ConfigurationTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -41,7 +41,7 @@ public enum MyEnum { ON, OFF, UNKNOWN - }; + } public MyEnum enumField = MyEnum.UNKNOWN; public int intField; diff --git a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/dto/ConfigDescriptionDTOTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/dto/ConfigDescriptionDTOTest.java index 28ce69994b5..4a9690f0576 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/dto/ConfigDescriptionDTOTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/dto/ConfigDescriptionDTOTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/test/java/org/openhab/core/config/core/internal/i18n/I18nConfigOptionsProviderTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/i18n/I18nConfigOptionsProviderTest.java index 735aefc11ec..b79af90b18c 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/i18n/I18nConfigOptionsProviderTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/i18n/I18nConfigOptionsProviderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/test/java/org/openhab/core/config/core/internal/metadata/MetadataConfigDescriptionProviderImplTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/metadata/MetadataConfigDescriptionProviderImplTest.java index 6879f00c132..1766a847eb4 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/metadata/MetadataConfigDescriptionProviderImplTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/metadata/MetadataConfigDescriptionProviderImplTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/test/java/org/openhab/core/config/core/internal/normalization/NormalizerTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/normalization/NormalizerTest.java index 76c85b675e2..e68f56692e7 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/normalization/NormalizerTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/normalization/NormalizerTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/test/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionValidatorTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionValidatorTest.java index 4edb68745b3..44755518f0f 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionValidatorTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/validation/ConfigDescriptionValidatorTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/test/java/org/openhab/core/config/core/internal/validation/ConfigValidationExceptionTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/validation/ConfigValidationExceptionTest.java index 29837752fb3..f0dc02ff813 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/validation/ConfigValidationExceptionTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/internal/validation/ConfigValidationExceptionTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/test/java/org/openhab/core/config/core/status/ConfigStatusInfoTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/status/ConfigStatusInfoTest.java index fe3cf2adf1f..0b24ad28c27 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/status/ConfigStatusInfoTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/status/ConfigStatusInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/test/java/org/openhab/core/config/core/status/ConfigStatusServiceTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/status/ConfigStatusServiceTest.java index 5f420ce5376..332630adffc 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/status/ConfigStatusServiceTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/core/status/ConfigStatusServiceTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.core/src/test/java/org/openhab/core/config/xml/util/XmlDocumentReaderTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/xml/util/XmlDocumentReaderTest.java index e778aa5323f..bf15cc4f266 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/xml/util/XmlDocumentReaderTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/openhab/core/config/xml/util/XmlDocumentReaderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +19,6 @@ import java.io.IOException; import java.net.URI; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; @@ -44,7 +43,7 @@ public class XmlDocumentReaderTest { private static final String OHC_PACKAGE_PREFIX = "org.openhab.core."; - private class ConfigDescriptionReader extends XmlDocumentReader { + private static class ConfigDescriptionReader extends XmlDocumentReader { @Override protected void registerConverters(XStream xstream) { } @@ -57,7 +56,7 @@ protected void registerAliases(XStream xstream) { private @Nullable ConfigDescription readXML(String xml) throws IOException { Path tempFile = Files.createTempFile(null, null); tempFile.toFile().deleteOnExit(); - Files.write(tempFile, xml.getBytes(StandardCharsets.UTF_8)); + Files.writeString(tempFile, xml); return new ConfigDescriptionReader().readFromXML(tempFile.toUri().toURL()); } @@ -85,7 +84,7 @@ public void defaultSecurityDisallowsDeserializingNonOHCobjects() throws Exceptio } /** - * @see https://x-stream.github.io/CVE-2013-7285.html + * @see XStream - CVE-2013-7285 */ @Test public void defaultSecurityProtectsAgainstRemoteCodeExecution() throws Exception { @@ -105,7 +104,7 @@ public void defaultSecurityProtectsAgainstRemoteCodeExecution() throws Exception } /** - * @see https://x-stream.github.io/CVE-2017-7957.html + * @see XStream - CVE-2017-7957 */ @Test public void defaultSecurityProtectsAgainstDenialOfServiceAttacks() throws Exception { diff --git a/bundles/org.openhab.core.config.discovery.addon.ip/.classpath b/bundles/org.openhab.core.config.discovery.addon.ip/.classpath new file mode 100644 index 00000000000..d3d6b3c11b6 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.ip/.classpath @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.openhab.core.config.discovery.addon.ip/.project b/bundles/org.openhab.core.config.discovery.addon.ip/.project new file mode 100644 index 00000000000..f2cee8bcbb9 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.ip/.project @@ -0,0 +1,23 @@ + + + org.openhab.core.config.discovery.addon.ip + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/bundles/org.openhab.core.config.discovery.addon.ip/NOTICE b/bundles/org.openhab.core.config.discovery.addon.ip/NOTICE new file mode 100644 index 00000000000..6c17d0d8a45 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.ip/NOTICE @@ -0,0 +1,14 @@ +This content is produced and maintained by the openHAB project. + +* Project home: https://www.openhab.org + +== Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License 2.0 which is available at +https://www.eclipse.org/legal/epl-2.0/. + +== Source Code + +https://github.com/openhab/openhab-core + diff --git a/bundles/org.openhab.core.config.discovery.addon.ip/pom.xml b/bundles/org.openhab.core.config.discovery.addon.ip/pom.xml new file mode 100644 index 00000000000..0c825cd2374 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.ip/pom.xml @@ -0,0 +1,29 @@ + + + + 4.0.0 + + + org.openhab.core.bundles + org.openhab.core.reactor.bundles + 4.2.0-SNAPSHOT + + + org.openhab.core.config.discovery.addon.ip + + openHAB Core :: Bundles :: IP-based Suggested Add-on Finder + + + + org.openhab.core.bundles + org.openhab.core.config.discovery.addon + ${project.version} + + + org.openhab.core.bundles + org.openhab.core.addon + ${project.version} + + + diff --git a/bundles/org.openhab.core.config.discovery.addon.ip/src/main/java/org/openhab/core/config/discovery/addon/ip/IpAddonFinder.java b/bundles/org.openhab.core.config.discovery.addon.ip/src/main/java/org/openhab/core/config/discovery/addon/ip/IpAddonFinder.java new file mode 100644 index 00000000000..33f4c5d8be5 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.ip/src/main/java/org/openhab/core/config/discovery/addon/ip/IpAddonFinder.java @@ -0,0 +1,479 @@ +/** + * 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.config.discovery.addon.ip; + +import static org.openhab.core.config.discovery.addon.AddonFinderConstants.*; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.net.Inet4Address; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.net.StandardProtocolFamily; +import java.net.StandardSocketOptions; +import java.net.UnknownHostException; +import java.nio.ByteBuffer; +import java.nio.channels.DatagramChannel; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.text.ParseException; +import java.util.HashSet; +import java.util.HexFormat; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.StringTokenizer; +import java.util.UUID; +import java.util.concurrent.CopyOnWriteArraySet; +import java.util.concurrent.Future; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.core.addon.Addon; +import org.openhab.core.addon.AddonDiscoveryMethod; +import org.openhab.core.addon.AddonInfo; +import org.openhab.core.addon.AddonMatchProperty; +import org.openhab.core.addon.AddonParameter; +import org.openhab.core.addon.AddonService; +import org.openhab.core.common.ThreadPoolManager; +import org.openhab.core.config.discovery.addon.AddonFinder; +import org.openhab.core.config.discovery.addon.BaseAddonFinder; +import org.openhab.core.net.NetUtil; +import org.openhab.core.util.StringUtils; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +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; + +/** + * This is a {@link IpAddonFinder} for finding suggested add-ons by sending IP packets to the + * network and collecting responses. + * + * This finder is intended to detect devices on the network which do not announce via UPnP + * or mDNS. Some devices respond to queries to defined multicast addresses and ports and thus + * can be detected by sending a single frame on the IP network. + *

    + * Be aware of possible side effects of sending packets to unknown devices in the network! + * This is why the IP finder is not intended for large scale network scanning, e.g. using + * large port or IP ranges. + *

    + * Configuration + *

    + * The following parameters can be used to configure frames to be sent to the network: + *

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    discovery-parametervaluescomment
    {@code type}ipMulticastno other options implemented
    {@code destIp}destination IP address
    {@code destPort}destination port
    {@code listenPort}port to use for listening to responses (optional)privileged ports ({@code <1024}) not allowed
    {@code request}description of request frame as hex bytes separated by spaces (e.g. 0x01 0x02 ...)dynamic replacement of variables $srcIp, $srcPort and $uuid, no others implemented yet + *
    {@code requestPlain}description of request frame as plaintext stringdynamic replacement of variables $srcIp, $srcPort and $uuid, no others implemented yet; + * there are five XML special characters which need to be escaped: + * + *
    {@code
    + * & - &
    + * < - <
    + * > - >
    + * " - "
    + * ' - '
    + * }
    + *
    {@code timeoutMs}timeout to wait for a answers
    + *

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    dynamic replacement (in {@code request*})value
    {@code $srcIp}source IP address
    {@code $srcPort}source port
    {@code $uuid}String returned by {@code java.util.UUID.randomUUID()}
    + *

    + * Packets are sent out on every available network interface. + *

    + * There is currently only one match-property defined: {@code response}. + * It allows a regex match, but currently only ".*" is supported. + *

    + * Limitations + *

    + * The {@link IpAddonFinder} is still under active development. + * There are limitations: + *

      + *
    • Currently every returned frame is considered as success, regex matching is not implemented. + *
    • Frames are sent only on startup (or if an {@link org.openhab.core.addon.AddonInfoProvider} + * calls {@link #setAddonCandidates(List)}), no background scanning. + *
        + * + * @apiNote The {@link IpAddonFinder} is still under active development, it has initially + * been developed to detect KNX installations and will be extended. Configuration parameters + * and supported features may still change. + * + * @implNote On activation, a thread is spawned which handles the detection. Scan runs once, + * no continuous background scanning. + * + * @author Holger Friedrich - Initial contribution + */ +@NonNullByDefault +@Component(service = AddonFinder.class, name = IpAddonFinder.SERVICE_NAME) +public class IpAddonFinder extends BaseAddonFinder { + + public static final String SERVICE_TYPE = SERVICE_TYPE_IP; + public static final String SERVICE_NAME = SERVICE_NAME_IP; + + private static final String TYPE_IP_MULTICAST = "ipMulticast"; + private static final String MATCH_PROPERTY_RESPONSE = "response"; + private static final String PARAMETER_DEST_IP = "destIp"; + private static final String PARAMETER_DEST_PORT = "destPort"; + private static final String PARAMETER_LISTEN_PORT = "listenPort"; + private static final String PARAMETER_REQUEST = "request"; + private static final String PARAMETER_REQUEST_PLAIN = "requestPlain"; + private static final String PARAMETER_SRC_IP = "srcIp"; + private static final String PARAMETER_SRC_PORT = "srcPort"; + private static final String PARAMETER_TIMEOUT_MS = "timeoutMs"; + private static final String REPLACEMENT_UUID = "uuid"; + + private final Logger logger = LoggerFactory.getLogger(IpAddonFinder.class); + private final ScheduledExecutorService scheduler = ThreadPoolManager + .getScheduledPool(ThreadPoolManager.THREAD_POOL_NAME_COMMON); + private final Set addonServices = new CopyOnWriteArraySet<>(); + private @Nullable Future scanJob = null; + Set suggestions = new HashSet<>(); + + public IpAddonFinder() { + logger.trace("IpAddonFinder::IpAddonFinder"); + // start of scan will be triggered by setAddonCandidates to ensure addonCandidates are available + } + + @Deactivate + public void deactivate() { + logger.trace("IpAddonFinder::deactivate"); + stopScan(); + } + + @Override + public void setAddonCandidates(List candidates) { + logger.debug("IpAddonFinder::setAddonCandidates({})", candidates.size()); + super.setAddonCandidates(candidates); + startScan(); + } + + @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) + protected void addAddonService(AddonService featureService) { + this.addonServices.add(featureService); + } + + protected void removeAddonService(AddonService featureService) { + this.addonServices.remove(featureService); + } + + private void startScan() { + // The setAddonCandidates() method is called for each info provider. + // In order to do the scan only once, but on the full set of candidates, we have to delay the execution. + // At the same time we must make sure that a scheduled scan is rescheduled - or (after more than our delay) is + // executed once more. + stopScan(); + logger.trace("Scheduling new IP scan"); + scanJob = scheduler.schedule(this::scan, 20, TimeUnit.SECONDS); + } + + private void stopScan() { + Future tmpScanJob = scanJob; + if (tmpScanJob != null) { + if (!tmpScanJob.isDone()) { + logger.trace("Trying to cancel IP scan"); + tmpScanJob.cancel(true); + } + scanJob = null; + } + } + + private void scan() { + logger.trace("IpAddonFinder::scan started"); + for (AddonInfo candidate : addonCandidates) { + for (AddonDiscoveryMethod method : candidate.getDiscoveryMethods().stream() + .filter(method -> SERVICE_TYPE.equals(method.getServiceType())).toList()) { + + logger.trace("Checking candidate: {}", candidate.getUID()); + + // skip scanning if already installed + if (isAddonInstalled(candidate.getUID())) { + logger.trace("Skipping {}, already installed", candidate.getUID()); + continue; + } + + Map parameters = method.getParameters().stream() + .collect(Collectors.toMap(AddonParameter::getName, AddonParameter::getValue)); + Map matchProperties = method.getMatchProperties().stream() + .collect(Collectors.toMap(AddonMatchProperty::getName, AddonMatchProperty::getRegex)); + + // parse standard set of parameters + String type = Objects.toString(parameters.get("type"), ""); + String request = Objects.toString(parameters.get(PARAMETER_REQUEST), ""); + String requestPlain = Objects.toString(parameters.get(PARAMETER_REQUEST_PLAIN), ""); + // xor + if (!("".equals(request) ^ "".equals(requestPlain))) { + logger.warn("{}: discovery-parameter '{}' or '{}' required", candidate.getUID(), PARAMETER_REQUEST, + PARAMETER_REQUEST_PLAIN); + continue; + } + String response = Objects.toString(matchProperties.get(MATCH_PROPERTY_RESPONSE), ""); + int timeoutMs; + try { + timeoutMs = Integer.parseInt(Objects.toString(parameters.get(PARAMETER_TIMEOUT_MS))); + } catch (NumberFormatException e) { + logger.warn("{}: discovery-parameter '{}' cannot be parsed", candidate.getUID(), + PARAMETER_TIMEOUT_MS); + continue; + } + @Nullable + InetAddress destIp; + try { + destIp = InetAddress.getByName(parameters.get(PARAMETER_DEST_IP)); + } catch (UnknownHostException e) { + logger.warn("{}: discovery-parameter '{}' cannot be parsed", candidate.getUID(), PARAMETER_DEST_IP); + continue; + } + int destPort; + try { + destPort = Integer.parseInt(Objects.toString(parameters.get(PARAMETER_DEST_PORT))); + } catch (NumberFormatException e) { + logger.warn("{}: discovery-parameter '{}' cannot be parsed", candidate.getUID(), + PARAMETER_DEST_PORT); + continue; + } + int listenPort = 0; // default, pick a non-privileged port + if (parameters.get(PARAMETER_LISTEN_PORT) != null) { + try { + listenPort = Integer.parseInt(Objects.toString(parameters.get(PARAMETER_LISTEN_PORT))); + } catch (NumberFormatException e) { + logger.warn("{}: discovery-parameter '{}' cannot be parsed", candidate.getUID(), + PARAMETER_LISTEN_PORT); + continue; + } + // do not allow privileged ports + if (listenPort < 1024) { + logger.warn("{}: discovery-parameter '{}' not allowed, privileged port", candidate.getUID(), + PARAMETER_LISTEN_PORT); + continue; + } + } + + // handle known types + try { + switch (Objects.toString(type)) { + case TYPE_IP_MULTICAST: + List ipAddresses = NetUtil.getAllInterfaceAddresses().stream() + .filter(a -> a.getAddress() instanceof Inet4Address) + .map(a -> a.getAddress().getHostAddress()).toList(); + + for (String localIp : ipAddresses) { + try (DatagramChannel channel = (DatagramChannel) DatagramChannel + .open(StandardProtocolFamily.INET) + .setOption(StandardSocketOptions.SO_REUSEADDR, true) + .bind(new InetSocketAddress(localIp, listenPort)) + .setOption(StandardSocketOptions.IP_MULTICAST_TTL, 64).configureBlocking(false); + Selector selector = Selector.open()) { + byte[] requestArray = "".equals(requestPlain) + ? buildRequestArray(channel, Objects.toString(request)) + : buildRequestArrayPlain(channel, Objects.toString(requestPlain)); + if (logger.isTraceEnabled()) { + InetSocketAddress sock = (InetSocketAddress) channel.getLocalAddress(); + String id = candidate.getUID(); + logger.trace("{}: probing {} -> {}:{}", id, localIp, + destIp != null ? destIp.getHostAddress() : "", destPort); + if (!"".equals(requestPlain)) { + logger.trace("{}: \'{}\'", id, new String(requestArray)); + } + logger.trace("{}: {}", id, + HexFormat.of().withDelimiter(" ").formatHex(requestArray)); + logger.trace("{}: listening on {}:{} for {} ms", id, + sock.getAddress().getHostAddress(), sock.getPort(), timeoutMs); + } + + channel.send(ByteBuffer.wrap(requestArray), + new InetSocketAddress(destIp, destPort)); + + // listen to responses + ByteBuffer buffer = ByteBuffer.wrap(new byte[50]); + channel.register(selector, SelectionKey.OP_READ); + selector.select(timeoutMs); + Iterator it = selector.selectedKeys().iterator(); + + switch (Objects.toString(response)) { + case ".*": + if (it.hasNext()) { + final SocketAddress source = ((DatagramChannel) it.next().channel()) + .receive(buffer); + logger.debug("Received return frame from {}", + ((InetSocketAddress) source).getAddress().getHostAddress()); + suggestions.add(candidate); + logger.debug("Suggested add-on found: {}", candidate.getUID()); + } else { + logger.trace("{}: no response received on {}", candidate.getUID(), + localIp); + } + break; + default: + logger.warn("{}: match-property response \"{}\" is unknown", + candidate.getUID(), type); + break; // end loop + } + } catch (IOException e) { + logger.debug("{}: network error", candidate.getUID(), e); + } + } + break; + + default: + logger.warn("{}: discovery-parameter type \"{}\" is unknown", candidate.getUID(), type); + } + } catch (ParseException | NumberFormatException none) { + continue; + } + } + } + logger.trace("IpAddonFinder::scan completed"); + } + + // build from plaintext string + private byte[] buildRequestArrayPlain(DatagramChannel channel, String request) + throws java.io.IOException, ParseException { + InetSocketAddress sock = (InetSocketAddress) channel.getLocalAddress(); + + // replace first + StringBuilder req = new StringBuilder(request); + int p; + while ((p = req.indexOf("$" + PARAMETER_SRC_IP)) != -1) { + req.replace(p, p + PARAMETER_SRC_IP.length() + 1, sock.getAddress().getHostAddress()); + } + while ((p = req.indexOf("$" + PARAMETER_SRC_PORT)) != -1) { + req.replace(p, p + PARAMETER_SRC_PORT.length() + 1, "" + sock.getPort()); + } + while ((p = req.indexOf("$" + REPLACEMENT_UUID)) != -1) { + req.replace(p, p + REPLACEMENT_UUID.length() + 1, UUID.randomUUID().toString()); + } + + @Nullable + String reqUnEscaped = StringUtils.unEscapeXml(req.toString()); + return reqUnEscaped != null ? reqUnEscaped.getBytes() : new byte[0]; + } + + // build from hex string + private byte[] buildRequestArray(DatagramChannel channel, String request) + throws java.io.IOException, ParseException { + InetSocketAddress sock = (InetSocketAddress) channel.getLocalAddress(); + + ByteArrayOutputStream requestFrame = new ByteArrayOutputStream(); + StringTokenizer parts = new StringTokenizer(request); + + while (parts.hasMoreTokens()) { + String token = parts.nextToken(); + if (token.startsWith("$")) { + switch (token) { + case "$" + PARAMETER_SRC_IP: + byte[] adr = sock.getAddress().getAddress(); + requestFrame.write(adr); + break; + case "$" + PARAMETER_SRC_PORT: + int dPort = sock.getPort(); + requestFrame.write((byte) ((dPort >> 8) & 0xff)); + requestFrame.write((byte) (dPort & 0xff)); + break; + case "$" + REPLACEMENT_UUID: + String uuid = UUID.randomUUID().toString(); + requestFrame.write(uuid.getBytes()); + break; + default: + logger.warn("Unknown token in request frame \"{}\"", token); + throw new ParseException(token, 0); + } + } else { + int i = Integer.decode(token); + requestFrame.write((byte) i); + } + } + return requestFrame.toByteArray(); + } + + @Override + public Set getSuggestedAddons() { + logger.trace("IpAddonFinder::getSuggestedAddons {}/{}", suggestions.size(), addonCandidates.size()); + return suggestions; + } + + @Override + public String getServiceName() { + return SERVICE_NAME; + } + + private boolean isAddonInstalled(String addonId) { + for (AddonService addonService : addonServices) { + Addon addon = addonService.getAddon(addonId, null); + if (addon != null && addon.isInstalled()) { + return true; + } + } + return false; + } +} diff --git a/bundles/org.openhab.core.config.discovery.addon.mdns/.classpath b/bundles/org.openhab.core.config.discovery.addon.mdns/.classpath new file mode 100644 index 00000000000..d3d6b3c11b6 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.mdns/.classpath @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.openhab.core.config.discovery.addon.mdns/.project b/bundles/org.openhab.core.config.discovery.addon.mdns/.project new file mode 100644 index 00000000000..00932f9e051 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.mdns/.project @@ -0,0 +1,23 @@ + + + org.openhab.core.config.discovery.addon.mdns + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/bundles/org.openhab.core.config.discovery.addon.mdns/NOTICE b/bundles/org.openhab.core.config.discovery.addon.mdns/NOTICE new file mode 100644 index 00000000000..6c17d0d8a45 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.mdns/NOTICE @@ -0,0 +1,14 @@ +This content is produced and maintained by the openHAB project. + +* Project home: https://www.openhab.org + +== Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License 2.0 which is available at +https://www.eclipse.org/legal/epl-2.0/. + +== Source Code + +https://github.com/openhab/openhab-core + diff --git a/bundles/org.openhab.core.config.discovery.addon.mdns/pom.xml b/bundles/org.openhab.core.config.discovery.addon.mdns/pom.xml new file mode 100644 index 00000000000..ab46d535b77 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.mdns/pom.xml @@ -0,0 +1,34 @@ + + + + 4.0.0 + + + org.openhab.core.bundles + org.openhab.core.reactor.bundles + 4.2.0-SNAPSHOT + + + org.openhab.core.config.discovery.addon.mdns + + openHAB Core :: Bundles :: mDNS Suggested Add-on Finder + + + + org.openhab.core.bundles + org.openhab.core.config.discovery.mdns + ${project.version} + + + org.openhab.core.bundles + org.openhab.core.config.discovery.addon + ${project.version} + + + org.openhab.core.bundles + org.openhab.core.addon + ${project.version} + + + diff --git a/bundles/org.openhab.core.config.discovery.addon.mdns/src/main/java/org/openhab/core/config/discovery/addon/mdns/MDNSAddonFinder.java b/bundles/org.openhab.core.config.discovery.addon.mdns/src/main/java/org/openhab/core/config/discovery/addon/mdns/MDNSAddonFinder.java new file mode 100644 index 00000000000..5b6ab00bfdf --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.mdns/src/main/java/org/openhab/core/config/discovery/addon/mdns/MDNSAddonFinder.java @@ -0,0 +1,195 @@ +/** + * 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.config.discovery.addon.mdns; + +import static org.openhab.core.config.discovery.addon.AddonFinderConstants.*; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ScheduledExecutorService; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import javax.jmdns.ServiceEvent; +import javax.jmdns.ServiceInfo; +import javax.jmdns.ServiceListener; + +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.addon.AddonMatchProperty; +import org.openhab.core.addon.AddonParameter; +import org.openhab.core.common.ThreadPoolManager; +import org.openhab.core.config.discovery.addon.AddonFinder; +import org.openhab.core.config.discovery.addon.BaseAddonFinder; +import org.openhab.core.io.transport.mdns.MDNSClient; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This is a {@link MDNSAddonFinder} for finding suggested add-ons via mDNS. This finder requires a + * {@code mdnsServiceType} parameter to be present in the add-on info discovery method. + * + * @author Andrew Fiddian-Green - Initial contribution + * @author Mark Herwege - refactor to allow uninstall + * @author Mark Herwege - change to discovery method schema + */ +@NonNullByDefault +@Component(service = AddonFinder.class, name = MDNSAddonFinder.SERVICE_NAME) +public class MDNSAddonFinder extends BaseAddonFinder implements ServiceListener { + + public static final String SERVICE_TYPE = SERVICE_TYPE_MDNS; + public static final String SERVICE_NAME = SERVICE_NAME_MDNS; + + public static final String MDNS_SERVICE_TYPE = "mdnsServiceType"; + + private static final String NAME = "name"; + private static final String APPLICATION = "application"; + + private final Logger logger = LoggerFactory.getLogger(MDNSAddonFinder.class); + private final ScheduledExecutorService scheduler = ThreadPoolManager.getScheduledPool(SERVICE_NAME); + private final Map services = new ConcurrentHashMap<>(); + private MDNSClient mdnsClient; + + @Activate + public MDNSAddonFinder(@Reference MDNSClient mdnsClient) { + this.mdnsClient = mdnsClient; + } + + /** + * Adds the given mDNS service to the set of discovered services. + * + * @param service the mDNS service to be added. + * @param isResolved indicates if mDNS has fully resolved the service information. + */ + public void addService(ServiceInfo service, boolean isResolved) { + String qualifiedName = service.getQualifiedName(); + if (isResolved || !services.containsKey(qualifiedName)) { + if (services.put(qualifiedName, service) == null) { + logger.trace("Added service: {}", qualifiedName); + } + } + } + + @Deactivate + public void deactivate() { + services.clear(); + unsetAddonCandidates(); + } + + @Override + public void setAddonCandidates(List candidates) { + // Remove listeners for all service types that are no longer in candidates + addonCandidates.stream().filter(c -> !candidates.contains(c)) + .forEach(c -> c.getDiscoveryMethods().stream().filter(m -> SERVICE_TYPE.equals(m.getServiceType())) + .filter(m -> !getMdnsServiceType(m).isEmpty()) + .forEach(m -> mdnsClient.removeServiceListener(getMdnsServiceType(m), this))); + + // Add listeners for all service types in candidates + super.setAddonCandidates(candidates); + addonCandidates + .forEach(c -> c.getDiscoveryMethods().stream().filter(m -> SERVICE_TYPE.equals(m.getServiceType())) + .filter(m -> !getMdnsServiceType(m).isEmpty()).forEach(m -> { + String serviceType = getMdnsServiceType(m); + mdnsClient.addServiceListener(serviceType, this); + scheduler.submit(() -> mdnsClient.list(serviceType)); + })); + } + + @Override + public void unsetAddonCandidates() { + addonCandidates.forEach(c -> c.getDiscoveryMethods().stream() + .filter(m -> SERVICE_TYPE.equals(m.getServiceType())).filter(m -> !getMdnsServiceType(m).isEmpty()) + .forEach(m -> mdnsClient.removeServiceListener(getMdnsServiceType(m), this))); + super.unsetAddonCandidates(); + } + + @Override + public Set getSuggestedAddons() { + Set result = new HashSet<>(); + for (AddonInfo candidate : addonCandidates) { + for (AddonDiscoveryMethod method : candidate.getDiscoveryMethods().stream() + .filter(method -> SERVICE_TYPE.equals(method.getServiceType())).toList()) { + Map matchProperties = method.getMatchProperties().stream() + .collect(Collectors.toMap(AddonMatchProperty::getName, AddonMatchProperty::getPattern)); + + Set matchPropertyKeys = matchProperties.keySet().stream() + .filter(property -> (!NAME.equals(property) && !APPLICATION.equals(property))) + .collect(Collectors.toSet()); + + logger.trace("Checking candidate: {}", candidate.getUID()); + for (ServiceInfo service : services.values()) { + + logger.trace("Checking service: {}/{}", service.getQualifiedName(), service.getNiceTextString()); + if (getMdnsServiceType(method).equals(service.getType()) + && propertyMatches(matchProperties, NAME, service.getName()) + && propertyMatches(matchProperties, APPLICATION, service.getApplication()) + && matchPropertyKeys.stream().allMatch( + name -> propertyMatches(matchProperties, name, service.getPropertyString(name)))) { + result.add(candidate); + logger.debug("Suggested add-on found: {}", candidate.getUID()); + break; + } + } + } + } + return result; + } + + private String getMdnsServiceType(AddonDiscoveryMethod method) { + String param = method.getParameters().stream().filter(p -> MDNS_SERVICE_TYPE.equals(p.getName())) + .map(AddonParameter::getValue).findFirst().orElse(""); + return param == null ? "" : param; + } + + @Override + public String getServiceName() { + return SERVICE_NAME; + } + + /* + * ************ MDNSClient call-back methods ************ + */ + + @Override + public void serviceAdded(@Nullable ServiceEvent event) { + if (event != null) { + ServiceInfo service = event.getInfo(); + if (service != null) { + addService(service, false); + } + } + } + + @Override + public void serviceRemoved(@Nullable ServiceEvent event) { + } + + @Override + public void serviceResolved(@Nullable ServiceEvent event) { + if (event != null) { + ServiceInfo service = event.getInfo(); + if (service != null) { + addService(service, true); + } + } + } +} diff --git a/bundles/org.openhab.core.config.discovery.addon.mdns/src/test/java/org/openhab/core/config/discovery/addon/mdns/tests/MDNSAddonFinderTests.java b/bundles/org.openhab.core.config.discovery.addon.mdns/src/test/java/org/openhab/core/config/discovery/addon/mdns/tests/MDNSAddonFinderTests.java new file mode 100644 index 00000000000..c45864e635a --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.mdns/src/test/java/org/openhab/core/config/discovery/addon/mdns/tests/MDNSAddonFinderTests.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.config.discovery.addon.mdns.tests; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.*; +import static org.openhab.core.config.discovery.addon.mdns.MDNSAddonFinder.MDNS_SERVICE_TYPE; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.jmdns.ServiceInfo; + +import org.eclipse.jdt.annotation.NonNullByDefault; +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; +import org.mockito.Mockito; +import org.openhab.core.addon.AddonDiscoveryMethod; +import org.openhab.core.addon.AddonInfo; +import org.openhab.core.addon.AddonMatchProperty; +import org.openhab.core.addon.AddonParameter; +import org.openhab.core.config.discovery.addon.AddonFinder; +import org.openhab.core.config.discovery.addon.AddonFinderConstants; +import org.openhab.core.config.discovery.addon.AddonSuggestionService; +import org.openhab.core.config.discovery.addon.mdns.MDNSAddonFinder; +import org.openhab.core.io.transport.mdns.MDNSClient; + +/** + * JUnit tests for the {@link AddonSuggestionService}. + * + * @author Andrew Fiddian-Green - Initial contribution + * @author Mark Herwege - Adapted to finders in separate packages + */ +@NonNullByDefault +@TestInstance(Lifecycle.PER_CLASS) +public class MDNSAddonFinderTests { + + private @NonNullByDefault({}) MDNSClient mdnsClient; + private @NonNullByDefault({}) AddonFinder addonFinder; + private List addonInfos = new ArrayList<>(); + + @BeforeAll + public void setup() { + setupMockMdnsClient(); + setupAddonInfos(); + createAddonFinder(); + } + + private void createAddonFinder() { + MDNSAddonFinder mdnsAddonFinder = new MDNSAddonFinder(mdnsClient); + assertNotNull(mdnsAddonFinder); + + for (ServiceInfo service : mdnsClient.list("_hue._tcp.local.")) { + mdnsAddonFinder.addService(service, true); + } + for (ServiceInfo service : mdnsClient.list("_printer._tcp.local.")) { + mdnsAddonFinder.addService(service, true); + } + + addonFinder = mdnsAddonFinder; + } + + private void setupMockMdnsClient() { + // create the mock + mdnsClient = mock(MDNSClient.class, Mockito.RETURNS_DEEP_STUBS); + when(mdnsClient.list(anyString())).thenReturn(new ServiceInfo[] {}); + ServiceInfo hueService = ServiceInfo.create("hue", "hue", 0, 0, 0, false, "hue service"); + when(mdnsClient.list(eq("_hue._tcp.local."))).thenReturn(new ServiceInfo[] { hueService }); + ServiceInfo hpService = ServiceInfo.create("printer", "hpprinter", 0, 0, 0, false, "hp printer service"); + hpService.setText(Map.of("ty", "hp printer", "rp", "anything")); + when(mdnsClient.list(eq("_printer._tcp.local."))).thenReturn(new ServiceInfo[] { hpService }); + + // check that it works + assertNotNull(mdnsClient); + ServiceInfo[] result; + result = mdnsClient.list("_printer._tcp.local."); + assertEquals(1, result.length); + assertEquals("hpprinter", result[0].getName()); + assertEquals(2, Collections.list(result[0].getPropertyNames()).size()); + assertEquals("hp printer", result[0].getPropertyString("ty")); + result = mdnsClient.list("_hue._tcp.local."); + assertEquals(1, result.length); + assertEquals("hue", result[0].getName()); + result = mdnsClient.list("aardvark"); + assertEquals(0, result.length); + } + + private void setupAddonInfos() { + AddonDiscoveryMethod hp = new AddonDiscoveryMethod().setServiceType(AddonFinderConstants.SERVICE_TYPE_MDNS) + .setMatchProperties( + List.of(new AddonMatchProperty("rp", ".*"), new AddonMatchProperty("ty", "hp (.*)"))) + .setParameters(List.of(new AddonParameter(MDNS_SERVICE_TYPE, "_printer._tcp.local."))); + addonInfos.add(AddonInfo.builder("hpprinter", "binding").withName("HP").withDescription("HP Printer") + .withDiscoveryMethods(List.of(hp)).build()); + + AddonDiscoveryMethod hue = new AddonDiscoveryMethod().setServiceType(AddonFinderConstants.SERVICE_TYPE_MDNS) + .setParameters(List.of(new AddonParameter(MDNS_SERVICE_TYPE, "_hue._tcp.local."))); + addonInfos.add(AddonInfo.builder("hue", "binding").withName("Hue").withDescription("Hue Bridge") + .withDiscoveryMethods(List.of(hue)).build()); + } + + @Test + public void testGetSuggestedAddons() { + addonFinder.setAddonCandidates(addonInfos); + Set addons = addonFinder.getSuggestedAddons(); + assertEquals(2, addons.size()); + assertFalse(addons.stream().anyMatch(a -> "aardvark".equals(a.getUID()))); + assertTrue(addons.stream().anyMatch(a -> "binding-hue".equals(a.getUID()))); + assertTrue(addons.stream().anyMatch(a -> "binding-hpprinter".equals(a.getUID()))); + } +} diff --git a/bundles/org.openhab.core.config.discovery.addon.process/.classpath b/bundles/org.openhab.core.config.discovery.addon.process/.classpath new file mode 100644 index 00000000000..d3d6b3c11b6 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.process/.classpath @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.openhab.core.config.discovery.addon.process/.project b/bundles/org.openhab.core.config.discovery.addon.process/.project new file mode 100644 index 00000000000..fefa8799dc2 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.process/.project @@ -0,0 +1,23 @@ + + + org.openhab.core.config.discovery.addon.process + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/bundles/org.openhab.core.config.discovery.addon.process/NOTICE b/bundles/org.openhab.core.config.discovery.addon.process/NOTICE new file mode 100644 index 00000000000..6c17d0d8a45 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.process/NOTICE @@ -0,0 +1,14 @@ +This content is produced and maintained by the openHAB project. + +* Project home: https://www.openhab.org + +== Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License 2.0 which is available at +https://www.eclipse.org/legal/epl-2.0/. + +== Source Code + +https://github.com/openhab/openhab-core + diff --git a/bundles/org.openhab.core.config.discovery.addon.process/pom.xml b/bundles/org.openhab.core.config.discovery.addon.process/pom.xml new file mode 100644 index 00000000000..f26a5100232 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.process/pom.xml @@ -0,0 +1,29 @@ + + + + 4.0.0 + + + org.openhab.core.bundles + org.openhab.core.reactor.bundles + 4.2.0-SNAPSHOT + + + org.openhab.core.config.discovery.addon.process + + openHAB Core :: Bundles :: Process-based Suggested Add-on Finder + + + + org.openhab.core.bundles + org.openhab.core.config.discovery.addon + ${project.version} + + + org.openhab.core.bundles + org.openhab.core.addon + ${project.version} + + + diff --git a/bundles/org.openhab.core.config.discovery.addon.process/src/main/java/org/openhab/core/config/discovery/addon/process/ProcessAddonFinder.java b/bundles/org.openhab.core.config.discovery.addon.process/src/main/java/org/openhab/core/config/discovery/addon/process/ProcessAddonFinder.java new file mode 100644 index 00000000000..c46b0d42320 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.process/src/main/java/org/openhab/core/config/discovery/addon/process/ProcessAddonFinder.java @@ -0,0 +1,141 @@ +/** + * 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.config.discovery.addon.process; + +import static org.openhab.core.config.discovery.addon.AddonFinderConstants.ADDON_SUGGESTION_FINDER; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +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.addon.AddonMatchProperty; +import org.openhab.core.config.discovery.addon.AddonFinder; +import org.openhab.core.config.discovery.addon.BaseAddonFinder; +import org.osgi.service.component.annotations.Component; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This is a {@link ProcessAddonFinder} for finding suggested add-ons by checking processes running + * on the openHAB server. + * + * @author Holger Friedrich - Initial contribution + */ +@NonNullByDefault +@Component(service = AddonFinder.class, name = ProcessAddonFinder.SERVICE_NAME) +public class ProcessAddonFinder extends BaseAddonFinder { + + public static final String SERVICE_TYPE = "process"; + public static final String CFG_FINDER_PROCESS = "suggestionFinderProcess"; + public static final String SERVICE_NAME = SERVICE_TYPE + ADDON_SUGGESTION_FINDER; + + private static final String COMMAND = "command"; + private static final String COMMAND_LINE = "commandLine"; + private static final Set SUPPORTED_PROPERTIES = Set.of(COMMAND, COMMAND_LINE); + + private final Logger logger = LoggerFactory.getLogger(ProcessAddonFinder.class); + + /** + * Private record to extract match property parameters from a {@link ProcessHandle.Info} object. + * Tries to mitigate differences on different operating systems. + */ + protected static record ProcessInfo(@Nullable String command, @Nullable String commandLine) { + + /** + * Initializes the command and commandLine fields. + * If the command field is not present, it parses the first token in the command line. + */ + protected static ProcessInfo from(ProcessHandle.Info info) { + String commandLine = info.commandLine().orElse(null); + String cmd = info.command().orElse(null); + if ((cmd == null || cmd.isEmpty()) && commandLine != null) { + cmd = commandLine; + String[] args = info.arguments().orElse(null); + if (args != null) { + for (int i = args.length - 1; i >= 0; i--) { + int index = cmd.lastIndexOf(args[i]); + if (index >= 0) { + cmd = cmd.substring(0, index); + } + } + } + cmd = cmd.stripTrailing(); + } + return new ProcessInfo(cmd, commandLine); + } + } + + @Override + public Set getSuggestedAddons() { + logger.trace("ProcessAddonFinder::getSuggestedAddons"); + Set result = new HashSet<>(); + Set processInfos; + + try { + processInfos = ProcessHandle.allProcesses().map(process -> ProcessInfo.from(process.info())) + .filter(info -> (info.command != null) || (info.commandLine != null)) + .collect(Collectors.toUnmodifiableSet()); + } catch (SecurityException | UnsupportedOperationException unused) { + logger.info("Cannot obtain process list, suggesting add-ons based on running processes is not possible"); + return result; + } + + for (AddonInfo candidate : addonCandidates) { + for (AddonDiscoveryMethod method : candidate.getDiscoveryMethods().stream() + .filter(method -> SERVICE_TYPE.equals(method.getServiceType())).toList()) { + + Map matchProperties = method.getMatchProperties().stream() + .collect(Collectors.toMap(AddonMatchProperty::getName, AddonMatchProperty::getPattern)); + + if (matchProperties.isEmpty()) { + logger.warn("Add-on info for '{}' contains no 'match-property'", candidate.getUID()); + break; + } + + Set propertyNames = new HashSet<>(matchProperties.keySet()); + boolean noSupportedProperty = !propertyNames.removeAll(SUPPORTED_PROPERTIES); + + if (!propertyNames.isEmpty()) { + logger.warn("Add-on info for '{}' contains unsupported 'match-property' [{}]", candidate.getUID(), + String.join(",", propertyNames)); + + if (noSupportedProperty) { + break; + } + } + + logger.trace("Checking candidate: {}", candidate.getUID()); + for (ProcessInfo processInfo : processInfos) { + if (propertyMatches(matchProperties, COMMAND, processInfo.command) + && propertyMatches(matchProperties, COMMAND_LINE, processInfo.commandLine)) { + result.add(candidate); + logger.debug("Suggested add-on found: {}", candidate.getUID()); + break; + } + } + } + } + return result; + } + + @Override + public String getServiceName() { + return SERVICE_NAME; + } +} diff --git a/bundles/org.openhab.core.config.discovery.addon.upnp/.classpath b/bundles/org.openhab.core.config.discovery.addon.upnp/.classpath new file mode 100644 index 00000000000..d3d6b3c11b6 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.upnp/.classpath @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.openhab.core.config.discovery.addon.upnp/.project b/bundles/org.openhab.core.config.discovery.addon.upnp/.project new file mode 100644 index 00000000000..f86bba378d1 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.upnp/.project @@ -0,0 +1,23 @@ + + + org.openhab.core.config.discovery.addon.upnp + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/bundles/org.openhab.core.config.discovery.addon.upnp/NOTICE b/bundles/org.openhab.core.config.discovery.addon.upnp/NOTICE new file mode 100644 index 00000000000..6c17d0d8a45 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.upnp/NOTICE @@ -0,0 +1,14 @@ +This content is produced and maintained by the openHAB project. + +* Project home: https://www.openhab.org + +== Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License 2.0 which is available at +https://www.eclipse.org/legal/epl-2.0/. + +== Source Code + +https://github.com/openhab/openhab-core + diff --git a/bundles/org.openhab.core.config.discovery.addon.upnp/pom.xml b/bundles/org.openhab.core.config.discovery.addon.upnp/pom.xml new file mode 100644 index 00000000000..cffbd119de2 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.upnp/pom.xml @@ -0,0 +1,29 @@ + + + + 4.0.0 + + + org.openhab.core.bundles + org.openhab.core.reactor.bundles + 4.2.0-SNAPSHOT + + + org.openhab.core.config.discovery.addon.upnp + + openHAB Core :: Bundles :: uPnP Suggested Add-on Finder + + + + org.openhab.core.bundles + org.openhab.core.config.discovery.addon + ${project.version} + + + org.openhab.core.bundles + org.openhab.core.addon + ${project.version} + + + diff --git a/bundles/org.openhab.core.config.discovery.addon.upnp/src/main/java/org/openhab/core/config/discovery/addon/upnp/UpnpAddonFinder.java b/bundles/org.openhab.core.config.discovery.addon.upnp/src/main/java/org/openhab/core/config/discovery/addon/upnp/UpnpAddonFinder.java new file mode 100644 index 00000000000..9248ceae43a --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.upnp/src/main/java/org/openhab/core/config/discovery/addon/upnp/UpnpAddonFinder.java @@ -0,0 +1,252 @@ +/** + * 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.config.discovery.addon.upnp; + +import static org.openhab.core.config.discovery.addon.AddonFinderConstants.SERVICE_NAME_UPNP; +import static org.openhab.core.config.discovery.addon.AddonFinderConstants.SERVICE_TYPE_UPNP; + +import java.net.URI; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.jupnp.UpnpService; +import org.jupnp.model.message.header.RootDeviceHeader; +import org.jupnp.model.meta.DeviceDetails; +import org.jupnp.model.meta.LocalDevice; +import org.jupnp.model.meta.ManufacturerDetails; +import org.jupnp.model.meta.ModelDetails; +import org.jupnp.model.meta.RemoteDevice; +import org.jupnp.model.meta.RemoteDeviceIdentity; +import org.jupnp.model.types.DeviceType; +import org.jupnp.model.types.UDN; +import org.jupnp.registry.Registry; +import org.jupnp.registry.RegistryListener; +import org.openhab.core.addon.AddonDiscoveryMethod; +import org.openhab.core.addon.AddonInfo; +import org.openhab.core.addon.AddonMatchProperty; +import org.openhab.core.config.discovery.addon.AddonFinder; +import org.openhab.core.config.discovery.addon.BaseAddonFinder; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This is a {@link UpnpAddonFinder} for finding suggested Addons via UPnP. + * + * @author Andrew Fiddian-Green - Initial contribution + * @author Mark Herwege - refactor to allow uninstall + */ +@NonNullByDefault +@Component(service = AddonFinder.class, name = UpnpAddonFinder.SERVICE_NAME) +public class UpnpAddonFinder extends BaseAddonFinder implements RegistryListener { + + public static final String SERVICE_TYPE = SERVICE_TYPE_UPNP; + public static final String SERVICE_NAME = SERVICE_NAME_UPNP; + + private static final String DEVICE_TYPE = "deviceType"; + private static final String MANUFACTURER = "manufacturer"; + private static final String MANUFACTURER_URI = "manufacturerURI"; + private static final String MODEL_NAME = "modelName"; + private static final String MODEL_NUMBER = "modelNumber"; + private static final String MODEL_DESCRIPTION = "modelDescription"; + private static final String MODEL_URI = "modelURI"; + private static final String SERIAL_NUMBER = "serialNumber"; + private static final String FRIENDLY_NAME = "friendlyName"; + + private static final Set SUPPORTED_PROPERTIES = Set.of(DEVICE_TYPE, MANUFACTURER, MANUFACTURER_URI, + MODEL_NAME, MODEL_NUMBER, MODEL_DESCRIPTION, MODEL_URI, SERIAL_NUMBER, FRIENDLY_NAME); + + private final Logger logger = LoggerFactory.getLogger(UpnpAddonFinder.class); + private final Map devices = new ConcurrentHashMap<>(); + private final UpnpService upnpService; + + @Activate + public UpnpAddonFinder(@Reference UpnpService upnpService) { + this.upnpService = upnpService; + + Registry registry = upnpService.getRegistry(); + for (RemoteDevice device : registry.getRemoteDevices()) { + remoteDeviceAdded(registry, device); + } + registry.addListener(this); + upnpService.getControlPoint().search(); + upnpService.getControlPoint().search(new RootDeviceHeader()); + } + + @Deactivate + public void deactivate() { + unsetAddonCandidates(); + + UpnpService upnpService = this.upnpService; + upnpService.getRegistry().removeListener(this); + + devices.clear(); + } + + /** + * Adds the given UPnP remote device to the set of discovered devices. + * + * @param device the UPnP remote device to be added. + */ + private void addDevice(RemoteDevice device) { + RemoteDeviceIdentity identity = device.getIdentity(); + if (identity != null) { + UDN udn = identity.getUdn(); + if (udn != null) { + String udnString = udn.getIdentifierString(); + if (devices.put(udnString, device) == null) { + logger.trace("Added device: {}", device.getDisplayString()); + } + } + } + } + + @Override + public Set getSuggestedAddons() { + Set result = new HashSet<>(); + for (AddonInfo candidate : addonCandidates) { + for (AddonDiscoveryMethod method : candidate.getDiscoveryMethods().stream() + .filter(method -> SERVICE_TYPE.equals(method.getServiceType())).toList()) { + Map matchProperties = method.getMatchProperties().stream() + .collect(Collectors.toMap(AddonMatchProperty::getName, AddonMatchProperty::getPattern)); + + Set propertyNames = new HashSet<>(matchProperties.keySet()); + propertyNames.removeAll(SUPPORTED_PROPERTIES); + + if (!propertyNames.isEmpty()) { + logger.warn("Add-on '{}' addon.xml file contains unsupported 'match-property' [{}]", + candidate.getUID(), String.join(",", propertyNames)); + break; + } + + logger.trace("Checking candidate: {}", candidate.getUID()); + for (RemoteDevice device : devices.values()) { + + String deviceType = null; + String serialNumber = null; + String friendlyName = null; + String manufacturer = null; + String manufacturerURI = null; + String modelName = null; + String modelNumber = null; + String modelDescription = null; + String modelURI = null; + + DeviceType devType = device.getType(); + if (devType != null) { + deviceType = devType.getType(); + } + + DeviceDetails devDetails = device.getDetails(); + if (devDetails != null) { + friendlyName = devDetails.getFriendlyName(); + serialNumber = devDetails.getSerialNumber(); + + ManufacturerDetails mfrDetails = devDetails.getManufacturerDetails(); + if (mfrDetails != null) { + URI mfrUri = mfrDetails.getManufacturerURI(); + manufacturer = mfrDetails.getManufacturer(); + manufacturerURI = mfrUri != null ? mfrUri.toString() : null; + } + + ModelDetails modDetails = devDetails.getModelDetails(); + if (modDetails != null) { + URI modUri = modDetails.getModelURI(); + modelName = modDetails.getModelName(); + modelDescription = modDetails.getModelDescription(); + modelNumber = modDetails.getModelNumber(); + modelURI = modUri != null ? modUri.toString() : null; + } + } + + logger.trace("Checking device: {}", device.getDisplayString()); + if (propertyMatches(matchProperties, DEVICE_TYPE, deviceType) + && propertyMatches(matchProperties, MANUFACTURER, manufacturer) + && propertyMatches(matchProperties, MANUFACTURER_URI, manufacturerURI) + && propertyMatches(matchProperties, MODEL_NAME, modelName) + && propertyMatches(matchProperties, MODEL_NUMBER, modelNumber) + && propertyMatches(matchProperties, MODEL_DESCRIPTION, modelDescription) + && propertyMatches(matchProperties, MODEL_URI, modelURI) + && propertyMatches(matchProperties, SERIAL_NUMBER, serialNumber) + && propertyMatches(matchProperties, FRIENDLY_NAME, friendlyName)) { + result.add(candidate); + logger.debug("Suggested add-on found: {}", candidate.getUID()); + break; + } + } + } + } + return result; + } + + @Override + public String getServiceName() { + return SERVICE_NAME; + } + + /* + * ************ UpnpService call-back methods ************ + */ + + @Override + public void afterShutdown() { + } + + @Override + public void beforeShutdown(@Nullable Registry registry) { + } + + @Override + public void localDeviceAdded(@Nullable Registry registry, @Nullable LocalDevice localDevice) { + } + + @Override + public void localDeviceRemoved(@Nullable Registry registry, @Nullable LocalDevice localDevice) { + } + + @Override + public void remoteDeviceAdded(@Nullable Registry registry, @Nullable RemoteDevice remoteDevice) { + if (remoteDevice != null) { + addDevice(remoteDevice); + } + } + + @Override + public void remoteDeviceDiscoveryFailed(@Nullable Registry registry, @Nullable RemoteDevice remoteDevice, + @Nullable Exception exception) { + } + + @Override + public void remoteDeviceDiscoveryStarted(@Nullable Registry registry, @Nullable RemoteDevice remoteDevice) { + } + + @Override + public void remoteDeviceRemoved(@Nullable Registry registry, @Nullable RemoteDevice remoteDevice) { + } + + @Override + public void remoteDeviceUpdated(@Nullable Registry registry, @Nullable RemoteDevice remoteDevice) { + if (remoteDevice != null) { + addDevice(remoteDevice); + } + } +} diff --git a/bundles/org.openhab.core.config.discovery.addon.upnp/src/test/java/org/openhab/core/config/discovery/addon/upnp/tests/UpnpAddonFinderTests.java b/bundles/org.openhab.core.config.discovery.addon.upnp/src/test/java/org/openhab/core/config/discovery/addon/upnp/tests/UpnpAddonFinderTests.java new file mode 100644 index 00000000000..f5ead8325d2 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.upnp/src/test/java/org/openhab/core/config/discovery/addon/upnp/tests/UpnpAddonFinderTests.java @@ -0,0 +1,137 @@ +/** + * 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.config.discovery.addon.upnp.tests; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.net.InetAddress; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +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; +import org.jupnp.UpnpService; +import org.jupnp.model.ValidationException; +import org.jupnp.model.meta.DeviceDetails; +import org.jupnp.model.meta.ManufacturerDetails; +import org.jupnp.model.meta.ModelDetails; +import org.jupnp.model.meta.RemoteDevice; +import org.jupnp.model.meta.RemoteDeviceIdentity; +import org.jupnp.model.meta.RemoteService; +import org.jupnp.model.types.DeviceType; +import org.jupnp.model.types.UDN; +import org.mockito.Mockito; +import org.openhab.core.addon.AddonDiscoveryMethod; +import org.openhab.core.addon.AddonInfo; +import org.openhab.core.addon.AddonMatchProperty; +import org.openhab.core.config.discovery.addon.AddonFinder; +import org.openhab.core.config.discovery.addon.AddonFinderConstants; +import org.openhab.core.config.discovery.addon.upnp.UpnpAddonFinder; + +/** + * JUnit tests for the {@link UpnpAddonFinder}. + * + * @author Andrew Fiddian-Green - Initial contribution + * @author Mark Herwege - Adapted to finders in separate packages + */ +@NonNullByDefault +@TestInstance(Lifecycle.PER_CLASS) +public class UpnpAddonFinderTests { + + private @NonNullByDefault({}) UpnpService upnpService; + private @NonNullByDefault({}) AddonFinder addonFinder; + private List addonInfos = new ArrayList<>(); + + @BeforeAll + public void setup() { + setupMockUpnpService(); + setupAddonInfos(); + createAddonFinder(); + } + + private void createAddonFinder() { + UpnpAddonFinder upnpAddonFinder = new UpnpAddonFinder(upnpService); + assertNotNull(upnpAddonFinder); + + addonFinder = upnpAddonFinder; + } + + private void setupMockUpnpService() { + // create the mock + upnpService = mock(UpnpService.class, Mockito.RETURNS_DEEP_STUBS); + URL url = null; + try { + url = new URL("http://www.openhab.org/"); + } catch (MalformedURLException e) { + fail("MalformedURLException"); + } + UDN udn = new UDN("udn"); + InetAddress address = null; + try { + address = InetAddress.getByName("127.0.0.1"); + } catch (UnknownHostException e) { + fail("UnknownHostException"); + } + RemoteDeviceIdentity identity = new RemoteDeviceIdentity(udn, 0, url, new byte[] {}, address); + DeviceType type = new DeviceType("nameSpace", "type"); + ManufacturerDetails manDetails = new ManufacturerDetails("manufacturer", "manufacturerURI"); + ModelDetails modDetails = new ModelDetails("Philips hue bridge", "modelDescription", "modelNumber", "modelURI"); + DeviceDetails devDetails = new DeviceDetails("friendlyName", manDetails, modDetails, "serialNumber", + "000123456789"); + List<@Nullable RemoteDevice> remoteDevices = new ArrayList<>(); + try { + remoteDevices.add(new RemoteDevice(identity, type, devDetails, (RemoteService) null)); + } catch (ValidationException e1) { + fail("ValidationException"); + } + when(upnpService.getRegistry().getRemoteDevices()).thenReturn(remoteDevices); + + // check that it works + assertNotNull(upnpService); + List result = new ArrayList<>(upnpService.getRegistry().getRemoteDevices()); + assertEquals(1, result.size()); + RemoteDevice device = result.get(0); + assertEquals("manufacturer", device.getDetails().getManufacturerDetails().getManufacturer()); + assertEquals("serialNumber", device.getDetails().getSerialNumber()); + } + + private void setupAddonInfos() { + AddonDiscoveryMethod hue = new AddonDiscoveryMethod().setServiceType(AddonFinderConstants.SERVICE_TYPE_UPNP) + .setMatchProperties(List.of(new AddonMatchProperty("modelName", "Philips hue bridge"))); + addonInfos.add(AddonInfo.builder("hue", "binding").withName("Hue").withDescription("Hue Bridge") + .withDiscoveryMethods(List.of(hue)).build()); + } + + @Test + public void testGetSuggestedAddons() { + addonFinder.setAddonCandidates(addonInfos); + Set addons = addonFinder.getSuggestedAddons(); + assertEquals(1, addons.size()); + assertFalse(addons.stream().anyMatch(a -> "aardvark".equals(a.getUID()))); + assertTrue(addons.stream().anyMatch(a -> "binding-hue".equals(a.getUID()))); + } +} diff --git a/bundles/org.openhab.core.config.discovery.addon.usb/.classpath b/bundles/org.openhab.core.config.discovery.addon.usb/.classpath new file mode 100644 index 00000000000..d3d6b3c11b6 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.usb/.classpath @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.openhab.core.config.discovery.addon.usb/.project b/bundles/org.openhab.core.config.discovery.addon.usb/.project new file mode 100644 index 00000000000..bf360c9c71e --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.usb/.project @@ -0,0 +1,23 @@ + + + org.openhab.core.config.discovery.addon.usb + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/bundles/org.openhab.core.config.discovery.addon.usb/NOTICE b/bundles/org.openhab.core.config.discovery.addon.usb/NOTICE new file mode 100644 index 00000000000..6c17d0d8a45 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.usb/NOTICE @@ -0,0 +1,14 @@ +This content is produced and maintained by the openHAB project. + +* Project home: https://www.openhab.org + +== Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License 2.0 which is available at +https://www.eclipse.org/legal/epl-2.0/. + +== Source Code + +https://github.com/openhab/openhab-core + diff --git a/bundles/org.openhab.core.config.discovery.addon.usb/pom.xml b/bundles/org.openhab.core.config.discovery.addon.usb/pom.xml new file mode 100644 index 00000000000..7ca3bcafc8d --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.usb/pom.xml @@ -0,0 +1,35 @@ + + + + 4.0.0 + + + org.openhab.core.bundles + org.openhab.core.reactor.bundles + 4.2.0-SNAPSHOT + + + org.openhab.core.config.discovery.addon.usb + + openHAB Core :: Bundles :: USB Suggested Add-on Finder + + + + org.openhab.core.bundles + org.openhab.core.config.discovery.addon + ${project.version} + + + org.openhab.core.bundles + org.openhab.core.addon + ${project.version} + + + org.openhab.core.bundles + org.openhab.core.config.discovery.usbserial + ${project.version} + + + + diff --git a/bundles/org.openhab.core.config.discovery.addon.usb/src/main/java/org/openhab/core/config/discovery/addon/usb/UsbAddonFinder.java b/bundles/org.openhab.core.config.discovery.addon.usb/src/main/java/org/openhab/core/config/discovery/addon/usb/UsbAddonFinder.java new file mode 100644 index 00000000000..f2e882949bb --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.usb/src/main/java/org/openhab/core/config/discovery/addon/usb/UsbAddonFinder.java @@ -0,0 +1,187 @@ +/** + * 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.config.discovery.addon.usb; + +import static org.openhab.core.config.discovery.addon.AddonFinderConstants.SERVICE_NAME_USB; +import static org.openhab.core.config.discovery.addon.AddonFinderConstants.SERVICE_TYPE_USB; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArraySet; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.core.addon.AddonDiscoveryMethod; +import org.openhab.core.addon.AddonInfo; +import org.openhab.core.addon.AddonMatchProperty; +import org.openhab.core.config.discovery.addon.AddonFinder; +import org.openhab.core.config.discovery.addon.BaseAddonFinder; +import org.openhab.core.config.discovery.usbserial.UsbSerialDeviceInformation; +import org.openhab.core.config.discovery.usbserial.UsbSerialDiscovery; +import org.openhab.core.config.discovery.usbserial.UsbSerialDiscoveryListener; +import org.osgi.service.component.annotations.Component; +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; + +/** + * This is a {@link AddonFinder} for finding suggested add-ons related to USB devices. + *

        + * It supports the following values for the 'match-property' 'name' element: + *

      • product - match on the product description text + *
      • manufacturer - match on the device manufacturer text + *
      • chipId - match on the chip vendor id plus product id + *
      • remote - match on whether the device is connected remotely or locally + * + * @author Andrew Fiddian-Green - Initial contribution + */ +@NonNullByDefault +@Component(service = AddonFinder.class, name = UsbAddonFinder.SERVICE_NAME) +public class UsbAddonFinder extends BaseAddonFinder implements UsbSerialDiscoveryListener { + + public static final String SERVICE_TYPE = SERVICE_TYPE_USB; + public static final String SERVICE_NAME = SERVICE_NAME_USB; + + /* + * Supported 'match-property' names + */ + public static final String PRODUCT = "product"; + public static final String MANUFACTURER = "manufacturer"; + public static final String CHIP_ID = "chipId"; + public static final String REMOTE = "remote"; + + public static final Set SUPPORTED_PROPERTIES = Set.of(PRODUCT, MANUFACTURER, CHIP_ID, REMOTE); + + private final Logger logger = LoggerFactory.getLogger(UsbAddonFinder.class); + private final Set usbSerialDiscoveries = new CopyOnWriteArraySet<>(); + private final Map usbDeviceInformations = new ConcurrentHashMap<>(); + + @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) + protected void addUsbSerialDiscovery(UsbSerialDiscovery usbSerialDiscovery) { + usbSerialDiscoveries.add(usbSerialDiscovery); + usbSerialDiscovery.registerDiscoveryListener(this); + usbSerialDiscovery.doSingleScan(); + } + + protected synchronized void removeUsbSerialDiscovery(UsbSerialDiscovery usbSerialDiscovery) { + usbSerialDiscovery.unregisterDiscoveryListener(this); + usbSerialDiscoveries.remove(usbSerialDiscovery); + } + + @Override + public Set getSuggestedAddons() { + Set result = new HashSet<>(); + for (AddonInfo candidate : addonCandidates) { + for (AddonDiscoveryMethod method : candidate.getDiscoveryMethods().stream() + .filter(method -> SERVICE_TYPE.equals(method.getServiceType())).toList()) { + Map matchProperties = method.getMatchProperties().stream() + .collect(Collectors.toMap(AddonMatchProperty::getName, AddonMatchProperty::getPattern)); + + Set propertyNames = new HashSet<>(matchProperties.keySet()); + propertyNames.removeAll(SUPPORTED_PROPERTIES); + + if (!propertyNames.isEmpty()) { + logger.warn("Add-on '{}' addon.xml file contains unsupported 'match-property' [{}]", + candidate.getUID(), String.join(",", propertyNames)); + break; + } + + logger.trace("Checking candidate: {}", candidate.getUID()); + for (UsbSerialDeviceInformation device : usbDeviceInformations.values()) { + logger.trace("Checking device: {}", device); + + if (propertyMatches(matchProperties, PRODUCT, device.getProduct()) + && propertyMatches(matchProperties, MANUFACTURER, device.getManufacturer()) + && propertyMatches(matchProperties, CHIP_ID, + getChipId(device.getVendorId(), device.getProductId())) + && propertyMatches(matchProperties, REMOTE, String.valueOf(device.getRemote()))) { + result.add(candidate); + logger.debug("Suggested add-on found: {}", candidate.getUID()); + break; + } + } + } + } + return result; + } + + private String getChipId(int vendorId, int productId) { + return String.format("%04x:%04x", vendorId, productId); + } + + @Override + public String getServiceName() { + return SERVICE_NAME; + } + + /** + * Create a unique 33 bit integer map hash key comprising the remote flag in the upper bit, the vendorId in the + * middle 16 bits, and the productId in the lower 16 bits. + */ + private long keyOf(UsbSerialDeviceInformation deviceInfo) { + return (deviceInfo.getRemote() ? 0x1_0000_0000L : 0) + (deviceInfo.getVendorId() * 0x1_0000L) + + deviceInfo.getProductId(); + } + + /** + * Add the discovered USB device information record to our internal map. If there is already an entry in the map + * then merge the two sets of data. + * + * @param discoveredInfo the newly discovered USB device information. + */ + @Override + public void usbSerialDeviceDiscovered(UsbSerialDeviceInformation discoveredInfo) { + UsbSerialDeviceInformation targetInfo = discoveredInfo; + UsbSerialDeviceInformation existingInfo = usbDeviceInformations.get(keyOf(targetInfo)); + + if (existingInfo != null) { + boolean isMerging = false; + String product = existingInfo.getProduct(); + if (product != null) { + product = discoveredInfo.getProduct(); + isMerging = true; + } + String manufacturer = existingInfo.getManufacturer(); + if (manufacturer != null) { + manufacturer = discoveredInfo.getManufacturer(); + isMerging = true; + } + String serialNumber = existingInfo.getSerialNumber(); + if (serialNumber != null) { + serialNumber = discoveredInfo.getSerialNumber(); + isMerging = true; + } + boolean remote = existingInfo.getRemote(); + if (remote == discoveredInfo.getRemote()) { + isMerging = true; + } + if (isMerging) { + targetInfo = new UsbSerialDeviceInformation(discoveredInfo.getVendorId(), discoveredInfo.getProductId(), + serialNumber, manufacturer, product, discoveredInfo.getInterfaceNumber(), + discoveredInfo.getInterfaceDescription(), discoveredInfo.getSerialPort()).setRemote(remote); + } + } + + usbDeviceInformations.put(keyOf(targetInfo), targetInfo); + } + + @Override + public void usbSerialDeviceRemoved(UsbSerialDeviceInformation removedInfo) { + usbDeviceInformations.remove(keyOf(removedInfo)); + } +} diff --git a/bundles/org.openhab.core.config.discovery.addon.usb/src/test/java/org/openhab/core/config/discovery/addon/usb/UsbAddonFinderTests.java b/bundles/org.openhab.core.config.discovery.addon.usb/src/test/java/org/openhab/core/config/discovery/addon/usb/UsbAddonFinderTests.java new file mode 100644 index 00000000000..b28ee2bf4c6 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon.usb/src/test/java/org/openhab/core/config/discovery/addon/usb/UsbAddonFinderTests.java @@ -0,0 +1,101 @@ +/** + * 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.config.discovery.addon.usb; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.openhab.core.addon.AddonDiscoveryMethod; +import org.openhab.core.addon.AddonInfo; +import org.openhab.core.addon.AddonMatchProperty; +import org.openhab.core.config.discovery.usbserial.UsbSerialDeviceInformation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import ch.qos.logback.classic.Level; + +/** + * This contains tests for the {@link UsbAddonFinder} class. + * + * @author Andrew Fiddian-Green - Initial contribution + */ +@NonNullByDefault +@TestInstance(Lifecycle.PER_CLASS) +class UsbAddonFinderTests { + + @Test + void testSuggestionFinder() { + Logger root = LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); + ((ch.qos.logback.classic.Logger) root).setLevel(Level.ERROR); + + AddonMatchProperty matchProperty = new AddonMatchProperty("product", "(?i).*zigbee.*"); + + AddonDiscoveryMethod discoveryMethod = new AddonDiscoveryMethod(); + discoveryMethod.setMatchProperties(List.of(matchProperty)).setServiceType("usb"); + + List addons = new ArrayList<>(); + addons.add(AddonInfo.builder("id", "binding").withName("name").withDescription("description") + .withDiscoveryMethods(List.of(discoveryMethod)).build()); + + UsbAddonFinder finder = new UsbAddonFinder(); + finder.setAddonCandidates(addons); + + finder.usbSerialDeviceDiscovered( + new UsbSerialDeviceInformation(0x123, 0x234, null, null, null, 0, "n/a", "n/a")); + + Set suggestions = finder.getSuggestedAddons(); + assertNotNull(suggestions); + assertTrue(suggestions.isEmpty()); + + finder.usbSerialDeviceDiscovered( + new UsbSerialDeviceInformation(0x345, 0x456, null, null, "some zigBEE product", 0, "n/a", "n/a")); + + suggestions = finder.getSuggestedAddons(); + assertNotNull(suggestions); + assertFalse(suggestions.isEmpty()); + } + + @Test + void testBadSyntax() { + Logger root = LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); + ((ch.qos.logback.classic.Logger) root).setLevel(Level.ERROR); + + AddonMatchProperty matchProperty = new AddonMatchProperty("aardvark", "(?i).*zigbee.*"); + + AddonDiscoveryMethod discoveryMethod = new AddonDiscoveryMethod(); + discoveryMethod.setMatchProperties(List.of(matchProperty)).setServiceType("usb"); + + List addons = new ArrayList<>(); + addons.add(AddonInfo.builder("id", "binding").withName("name").withDescription("description") + .withDiscoveryMethods(List.of(discoveryMethod)).build()); + + UsbAddonFinder finder = new UsbAddonFinder(); + finder.setAddonCandidates(addons); + + finder.usbSerialDeviceDiscovered( + new UsbSerialDeviceInformation(0x123, 0x234, null, null, null, 0, "n/a", "n/a")); + + Set suggestions = finder.getSuggestedAddons(); + assertNotNull(suggestions); + assertTrue(suggestions.isEmpty()); + } +} diff --git a/bundles/org.openhab.core.config.discovery.addon/.classpath b/bundles/org.openhab.core.config.discovery.addon/.classpath new file mode 100644 index 00000000000..e9d63b05acb --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon/.classpath @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.openhab.core.config.discovery.addon/.project b/bundles/org.openhab.core.config.discovery.addon/.project new file mode 100644 index 00000000000..ea7024024f2 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon/.project @@ -0,0 +1,23 @@ + + + org.openhab.core.config.discovery.addon + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/bundles/org.openhab.core.config.discovery.addon/NOTICE b/bundles/org.openhab.core.config.discovery.addon/NOTICE new file mode 100644 index 00000000000..6c17d0d8a45 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon/NOTICE @@ -0,0 +1,14 @@ +This content is produced and maintained by the openHAB project. + +* Project home: https://www.openhab.org + +== Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License 2.0 which is available at +https://www.eclipse.org/legal/epl-2.0/. + +== Source Code + +https://github.com/openhab/openhab-core + diff --git a/bundles/org.openhab.core.config.discovery.addon/pom.xml b/bundles/org.openhab.core.config.discovery.addon/pom.xml new file mode 100644 index 00000000000..2d1c396ad5c --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon/pom.xml @@ -0,0 +1,24 @@ + + + + 4.0.0 + + + org.openhab.core.bundles + org.openhab.core.reactor.bundles + 4.2.0-SNAPSHOT + + + org.openhab.core.config.discovery.addon + + openHAB Core :: Bundles :: Add-on Suggestion Service + + + + org.openhab.core.bundles + org.openhab.core.addon + ${project.version} + + + diff --git a/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/AddonFinder.java b/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/AddonFinder.java new file mode 100644 index 00000000000..d58018bc627 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/AddonFinder.java @@ -0,0 +1,48 @@ +/** + * 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.config.discovery.addon; + +import java.util.List; +import java.util.Set; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.core.addon.AddonInfo; + +/** + * This is a {@link AddonFinder} interface for classes that find add-ons that are suggested to be installed. + * + * @author Andrew Fiddian-Green - Initial contribution + */ +@NonNullByDefault +public interface AddonFinder { + + /** + * The framework calls this method to scan through the candidate list of {@link AddonInfo} and return a subset of + * those that it suggests to be installed. + */ + Set getSuggestedAddons(); + + /** + * The framework calls this method to provide a list of {@link AddonInfo} elements which contain potential + * candidates that this finder can iterate over in order to detect which ones to return via the + * {@code getSuggestedAddons()} method. + * + * @param candidates a list of AddonInfo candidates. + */ + void setAddonCandidates(List candidates); + + /** + * This method should be called from the framework to allow a finder to stop searching for add-ons and do cleanup. + */ + void unsetAddonCandidates(); +} diff --git a/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/AddonFinderConstants.java b/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/AddonFinderConstants.java new file mode 100644 index 00000000000..2d6a43ef96c --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/AddonFinderConstants.java @@ -0,0 +1,59 @@ +/** + * 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.config.discovery.addon; + +import java.util.List; +import java.util.Map; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * This {@link AddonFinderConstants} contains constants describing add-on finders available in core. + * + * @author Mark Herwege - Initial contribution + */ +@NonNullByDefault +public class AddonFinderConstants { + + public static final String ADDON_SUGGESTION_FINDER = "-addon-suggestion-finder"; + private static final String ADDON_SUGGESTION_FINDER_FEATURE = "openhab-core-config-discovery-addon-"; + + public static final String SERVICE_TYPE_IP = "ip"; + public static final String CFG_FINDER_IP = "suggestionFinderIp"; + public static final String SERVICE_NAME_IP = SERVICE_TYPE_IP + ADDON_SUGGESTION_FINDER; + public static final String FEATURE_IP = ADDON_SUGGESTION_FINDER_FEATURE + SERVICE_TYPE_IP; + + public static final String SERVICE_TYPE_MDNS = "mdns"; + public static final String CFG_FINDER_MDNS = "suggestionFinderMdns"; + public static final String SERVICE_NAME_MDNS = SERVICE_TYPE_MDNS + ADDON_SUGGESTION_FINDER; + public static final String FEATURE_MDNS = ADDON_SUGGESTION_FINDER_FEATURE + SERVICE_TYPE_MDNS; + + public static final String SERVICE_TYPE_UPNP = "upnp"; + public static final String CFG_FINDER_UPNP = "suggestionFinderUpnp"; + public static final String SERVICE_NAME_UPNP = SERVICE_TYPE_UPNP + ADDON_SUGGESTION_FINDER; + public static final String FEATURE_UPNP = ADDON_SUGGESTION_FINDER_FEATURE + SERVICE_TYPE_UPNP; + + public static final String SERVICE_TYPE_USB = "usb"; + public static final String CFG_FINDER_USB = "suggestionFinderUsb"; + public static final String SERVICE_NAME_USB = SERVICE_TYPE_USB + ADDON_SUGGESTION_FINDER; + public static final String FEATURE_USB = ADDON_SUGGESTION_FINDER_FEATURE + SERVICE_TYPE_USB; + + public static final List SUGGESTION_FINDERS = List.of(SERVICE_NAME_IP, SERVICE_NAME_MDNS, SERVICE_NAME_UPNP, + SERVICE_NAME_USB); + + public static final Map SUGGESTION_FINDER_CONFIGS = Map.of(SERVICE_NAME_IP, CFG_FINDER_IP, + SERVICE_NAME_MDNS, CFG_FINDER_MDNS, SERVICE_NAME_UPNP, CFG_FINDER_UPNP, SERVICE_NAME_USB, CFG_FINDER_USB); + + public static final Map SUGGESTION_FINDER_FEATURES = Map.of(SERVICE_NAME_IP, FEATURE_IP, + SERVICE_NAME_MDNS, FEATURE_MDNS, SERVICE_NAME_UPNP, FEATURE_UPNP, SERVICE_NAME_USB, FEATURE_USB); +} diff --git a/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/AddonFinderService.java b/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/AddonFinderService.java new file mode 100644 index 00000000000..fb0013ea90c --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/AddonFinderService.java @@ -0,0 +1,43 @@ +/** + * 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.config.discovery.addon; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Classes implementing this interface can be registered as an OSGi service in order to provide functionality for + * managing add-on suggestion finders, such as installing and uninstalling them. + * + * @author Mark Herwege - Initial contribution + */ +@NonNullByDefault +public interface AddonFinderService { + + /** + * Installs the given add-on suggestion finder. + * + * This can be a long running process. The framework makes sure that this is called within a separate thread. + * + * @param id the id of the add-on suggestion finder to install + */ + void install(String id); + + /** + * Uninstalls the given add-on suggestion finder. + * + * This can be a long running process. The framework makes sure that this is called within a separate thread. + * + * @param id the id of the add-on suggestion finder to uninstall + */ + void uninstall(String id); +} diff --git a/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/AddonSuggestionService.java b/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/AddonSuggestionService.java new file mode 100644 index 00000000000..8e249ee096e --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/AddonSuggestionService.java @@ -0,0 +1,214 @@ +/** + * 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.config.discovery.addon; + +import static org.openhab.core.config.discovery.addon.AddonFinderConstants.*; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.Future; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.core.addon.AddonInfo; +import org.openhab.core.addon.AddonInfoProvider; +import org.openhab.core.common.ThreadPoolManager; +import org.openhab.core.config.core.ConfigParser; +import org.openhab.core.i18n.LocaleProvider; +import org.osgi.service.cm.ConfigurationAdmin; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Modified; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.component.annotations.ReferenceCardinality; +import org.osgi.service.component.annotations.ReferencePolicy; +import org.osgi.service.component.annotations.ReferencePolicyOption; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This is a {@link AddonSuggestionService} which discovers suggested add-ons for the user to install. + * + * @author Andrew Fiddian-Green - Initial contribution + * @author Mark Herwege - Install/remove finders + */ +@NonNullByDefault +@Component(immediate = true, service = AddonSuggestionService.class, name = AddonSuggestionService.SERVICE_NAME, configurationPid = AddonSuggestionService.CONFIG_PID) +public class AddonSuggestionService implements AutoCloseable { + + public static final String SERVICE_NAME = "addon-suggestion-service"; + public static final String CONFIG_PID = "org.openhab.addons"; + + private final Logger logger = LoggerFactory.getLogger(AddonSuggestionService.class); + + private final Set addonInfoProviders = ConcurrentHashMap.newKeySet(); + private final List addonFinders = Collections.synchronizedList(new ArrayList<>()); + private final ConfigurationAdmin configurationAdmin; + private final LocaleProvider localeProvider; + private @Nullable AddonFinderService addonFinderService; + private @Nullable Map config; + private final ScheduledExecutorService scheduler; + private final Map baseFinderConfig = new ConcurrentHashMap<>(); + private final List> tasks = new CopyOnWriteArrayList<>(); + + @Activate + public AddonSuggestionService(final @Reference ConfigurationAdmin configurationAdmin, + @Reference LocaleProvider localeProvider, @Nullable Map config) { + this.configurationAdmin = configurationAdmin; + this.localeProvider = localeProvider; + + SUGGESTION_FINDERS.forEach(f -> baseFinderConfig.put(f, true)); + modified(config); + changed(); + + // Changes to the configuration are expected to call the {@link modified} method. This works well when running + // in Eclipse. Running in Karaf, the method was not consistently called. Therefore regularly check for changes + // in configuration. + // This pattern and code was re-used from {@link org.openhab.core.karaf.internal.FeatureInstaller} + scheduler = ThreadPoolManager.getScheduledPool(ThreadPoolManager.THREAD_POOL_NAME_COMMON); + tasks.add(scheduler.scheduleWithFixedDelay(this::syncConfiguration, 1, 1, TimeUnit.MINUTES)); + } + + @Deactivate + protected void deactivate() { + tasks.forEach(task -> task.cancel(true)); + } + + @Reference(cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY) + protected void addAddonFinderService(AddonFinderService addonFinderService) { + this.addonFinderService = addonFinderService; + modified(config); + } + + protected void removeAddonFinderService(AddonFinderService addonFinderService) { + AddonFinderService finderService = this.addonFinderService; + if ((finderService != null) && addonFinderService.getClass().isAssignableFrom(finderService.getClass())) { + this.addonFinderService = null; + } + } + + @Modified + public void modified(@Nullable final Map config) { + baseFinderConfig.forEach((finder, cfg) -> { + String cfgParam = SUGGESTION_FINDER_CONFIGS.get(finder); + if (cfgParam != null) { + boolean enabled = (config != null) + ? ConfigParser.valueAsOrElse(config.get(cfgParam), Boolean.class, cfg) + : cfg; + baseFinderConfig.put(finder, enabled); + String feature = SUGGESTION_FINDER_FEATURES.get(finder); + AddonFinderService finderService = addonFinderService; + if (feature != null && finderService != null) { + if (enabled) { + tasks.add(scheduler.submit(() -> finderService.install(feature))); + } else { + tasks.add(scheduler.submit(() -> finderService.uninstall(feature))); + } + } + } + }); + this.config = config; + } + + private void syncConfiguration() { + try { + Dictionary cfg = configurationAdmin.getConfiguration(CONFIG_PID).getProperties(); + if (cfg == null) { + return; + } + final Map cfgMap = new HashMap<>(); + final Enumeration enumeration = cfg.keys(); + while (enumeration.hasMoreElements()) { + final String key = enumeration.nextElement(); + cfgMap.put(key, cfg.get(key)); + } + if (!cfgMap.equals(config)) { + modified(cfgMap); + } + } catch (IOException | IllegalStateException e) { + logger.debug("Exception occurred while trying to sync the configuration: {}", e.getMessage()); + } + } + + private boolean isFinderEnabled(AddonFinder finder) { + if (finder instanceof BaseAddonFinder baseFinder) { + return baseFinderConfig.getOrDefault(baseFinder.getServiceName(), true); + } + return true; + } + + @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) + public void addAddonInfoProvider(AddonInfoProvider addonInfoProvider) { + addonInfoProviders.add(addonInfoProvider); + changed(); + } + + public void removeAddonInfoProvider(AddonInfoProvider addonInfoProvider) { + if (addonInfoProviders.remove(addonInfoProvider)) { + changed(); + } + } + + @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) + public void addAddonFinder(AddonFinder addonFinder) { + synchronized (addonFinders) { + addonFinders.add(addonFinder); + } + changed(); + } + + public void removeAddonFinder(AddonFinder addonFinder) { + synchronized (addonFinders) { + addonFinders.remove(addonFinder); + } + } + + private void changed() { + List candidates = addonInfoProviders.stream().map(p -> p.getAddonInfos(localeProvider.getLocale())) + .flatMap(Collection::stream).toList(); + synchronized (addonFinders) { + addonFinders.stream().filter(this::isFinderEnabled).forEach(f -> f.setAddonCandidates(candidates)); + } + } + + @Deactivate + @Override + public void close() throws Exception { + synchronized (addonFinders) { + addonFinders.clear(); + } + addonInfoProviders.clear(); + } + + public Set getSuggestedAddons(@Nullable Locale locale) { + synchronized (addonFinders) { + return addonFinders.stream().filter(this::isFinderEnabled).map(f -> f.getSuggestedAddons()) + .flatMap(Collection::stream).collect(Collectors.toSet()); + } + } +} diff --git a/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/BaseAddonFinder.java b/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/BaseAddonFinder.java new file mode 100644 index 00000000000..42165b6e257 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/BaseAddonFinder.java @@ -0,0 +1,60 @@ +/** + * 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.config.discovery.addon; + +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.core.addon.AddonInfo; + +/** + * This is a {@link BaseAddonFinder} abstract class for finding suggested add-ons. + * + * @author Andrew Fiddian-Green - Initial contribution + */ +@NonNullByDefault +public abstract class BaseAddonFinder implements AddonFinder { + + /** + * Helper method to check if the given {@code propertyName} is in the {@code propertyPatternMap} and if so, the + * given {@code propertyValue} matches the respective regular expression {@code Pattern}. + * + * @param propertyPatternMap map of property names and regex patterns for value matching + * @param propertyName + * @param propertyValue + * @return true a) if the property name exists and the property value is not null and matches the regular + * expression, or b) the property name does not exist. + */ + protected static boolean propertyMatches(Map propertyPatternMap, String propertyName, + @Nullable String propertyValue) { + Pattern pattern = propertyPatternMap.get(propertyName); + return pattern == null || (propertyValue != null && pattern.matcher(propertyValue).matches()); + } + + protected volatile List addonCandidates = List.of(); + + @Override + public void setAddonCandidates(List candidates) { + addonCandidates = candidates; + } + + @Override + public void unsetAddonCandidates() { + addonCandidates = List.of(); + } + + public abstract String getServiceName(); +} diff --git a/bundles/org.openhab.core.config.discovery.addon/src/test/java/org/openhab/core/config/discovery/addon/tests/AddonSuggestionServiceTests.java b/bundles/org.openhab.core.config.discovery.addon/src/test/java/org/openhab/core/config/discovery/addon/tests/AddonSuggestionServiceTests.java new file mode 100644 index 00000000000..e880768cd34 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.addon/src/test/java/org/openhab/core/config/discovery/addon/tests/AddonSuggestionServiceTests.java @@ -0,0 +1,199 @@ +/** + * 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.config.discovery.addon.tests; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; +import static org.openhab.core.config.discovery.addon.AddonFinderConstants.*; + +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.junit.jupiter.api.AfterAll; +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; +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.openhab.core.addon.AddonParameter; +import org.openhab.core.config.discovery.addon.AddonFinder; +import org.openhab.core.config.discovery.addon.AddonFinderConstants; +import org.openhab.core.config.discovery.addon.AddonSuggestionService; +import org.openhab.core.i18n.LocaleProvider; +import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationAdmin; + +/** + * JUnit tests for the {@link AddonSuggestionService}. + * + * @author Andrew Fiddian-Green - Initial contribution + * @author Mark Herwege - Adapted to finders in separate packages + */ +@NonNullByDefault +@TestInstance(Lifecycle.PER_CLASS) +public class AddonSuggestionServiceTests { + + public static final String MDNS_SERVICE_TYPE = "mdnsServiceType"; + + private @NonNullByDefault({}) ConfigurationAdmin configurationAdmin; + private @NonNullByDefault({}) LocaleProvider localeProvider; + private @NonNullByDefault({}) AddonInfoProvider addonInfoProvider; + private @NonNullByDefault({}) AddonFinder mdnsAddonFinder; + private @NonNullByDefault({}) AddonFinder upnpAddonFinder; + private @NonNullByDefault({}) AddonSuggestionService addonSuggestionService; + + private final Map config = Map.of(AddonFinderConstants.CFG_FINDER_MDNS, true, + AddonFinderConstants.CFG_FINDER_UPNP, true); + + @AfterAll + public void cleanUp() { + assertNotNull(addonSuggestionService); + try { + addonSuggestionService.close(); + } catch (Exception e) { + fail(e); + } + } + + @BeforeAll + public void setup() { + setupMockConfigurationAdmin(); + setupMockLocaleProvider(); + setupMockAddonInfoProvider(); + setupMockMdnsAddonFinder(); + setupMockUpnpAddonFinder(); + addonSuggestionService = createAddonSuggestionService(); + } + + private AddonSuggestionService createAddonSuggestionService() { + AddonSuggestionService addonSuggestionService = new AddonSuggestionService(configurationAdmin, localeProvider, + config); + assertNotNull(addonSuggestionService); + + addonSuggestionService.addAddonFinder(mdnsAddonFinder); + addonSuggestionService.addAddonFinder(upnpAddonFinder); + + return addonSuggestionService; + } + + private void setupMockConfigurationAdmin() { + // create the mock + configurationAdmin = mock(ConfigurationAdmin.class); + Configuration configuration = mock(Configuration.class); + try { + when(configurationAdmin.getConfiguration(any())).thenReturn(configuration); + } catch (IOException e) { + } + when(configuration.getProperties()).thenReturn(null); + + // check that it works + assertNotNull(configurationAdmin); + try { + assertNull(configurationAdmin.getConfiguration(AddonSuggestionService.CONFIG_PID).getProperties()); + } catch (IOException e) { + } + } + + private void setupMockLocaleProvider() { + // create the mock + localeProvider = mock(LocaleProvider.class); + when(localeProvider.getLocale()).thenReturn(Locale.US); + + // check that it works + assertNotNull(localeProvider); + assertEquals(Locale.US, localeProvider.getLocale()); + } + + private void setupMockAddonInfoProvider() { + AddonDiscoveryMethod hp = new AddonDiscoveryMethod().setServiceType(AddonFinderConstants.SERVICE_TYPE_MDNS) + .setMatchProperties( + List.of(new AddonMatchProperty("rp", ".*"), new AddonMatchProperty("ty", "hp (.*)"))) + .setParameters(List.of(new AddonParameter(MDNS_SERVICE_TYPE, "_printer._tcp.local."))); + + AddonDiscoveryMethod hue1 = new AddonDiscoveryMethod().setServiceType(AddonFinderConstants.SERVICE_TYPE_UPNP) + .setMatchProperties(List.of(new AddonMatchProperty("modelName", "Philips hue bridge"))); + + AddonDiscoveryMethod hue2 = new AddonDiscoveryMethod().setServiceType(AddonFinderConstants.SERVICE_TYPE_MDNS) + .setParameters(List.of(new AddonParameter(MDNS_SERVICE_TYPE, "_hue._tcp.local."))); + + // create the mock + addonInfoProvider = mock(AddonInfoProvider.class); + Set addonInfos = new HashSet<>(); + addonInfos.add(AddonInfo.builder("hue", "binding").withName("Hue").withDescription("Hue Bridge") + .withDiscoveryMethods(List.of(hue1, hue2)).build()); + + addonInfos.add(AddonInfo.builder("hpprinter", "binding").withName("HP").withDescription("HP Printer") + .withDiscoveryMethods(List.of(hp)).build()); + when(addonInfoProvider.getAddonInfos(any(Locale.class))).thenReturn(addonInfos); + + // check that it works + assertNotNull(addonInfoProvider); + Set addonInfos2 = addonInfoProvider.getAddonInfos(Locale.US); + assertEquals(2, addonInfos2.size()); + assertTrue(addonInfos2.stream().anyMatch(a -> "binding-hue".equals(a.getUID()))); + assertTrue(addonInfos2.stream().anyMatch(a -> "binding-hpprinter".equals(a.getUID()))); + } + + private void setupMockMdnsAddonFinder() { + // create the mock + mdnsAddonFinder = mock(AddonFinder.class); + + Set addonInfos = addonInfoProvider.getAddonInfos(Locale.US).stream().filter( + c -> c.getDiscoveryMethods().stream().anyMatch(m -> SERVICE_TYPE_MDNS.equals(m.getServiceType()))) + .collect(Collectors.toSet()); + when(mdnsAddonFinder.getSuggestedAddons()).thenReturn(addonInfos); + + // check that it works + assertNotNull(mdnsAddonFinder); + Set addonInfos2 = mdnsAddonFinder.getSuggestedAddons(); + assertEquals(2, addonInfos2.size()); + assertTrue(addonInfos2.stream().anyMatch(a -> "binding-hue".equals(a.getUID()))); + assertTrue(addonInfos2.stream().anyMatch(a -> "binding-hpprinter".equals(a.getUID()))); + } + + private void setupMockUpnpAddonFinder() { + // create the mock + upnpAddonFinder = mock(AddonFinder.class); + + Set addonInfos = addonInfoProvider.getAddonInfos(Locale.US).stream().filter( + c -> c.getDiscoveryMethods().stream().anyMatch(m -> SERVICE_TYPE_UPNP.equals(m.getServiceType()))) + .collect(Collectors.toSet()); + when(upnpAddonFinder.getSuggestedAddons()).thenReturn(addonInfos); + + // check that it works + assertNotNull(upnpAddonFinder); + Set addonInfos2 = upnpAddonFinder.getSuggestedAddons(); + assertEquals(1, addonInfos2.size()); + assertTrue(addonInfos2.stream().anyMatch(a -> "binding-hue".equals(a.getUID()))); + } + + @Test + public void testGetSuggestedAddons() { + addonSuggestionService.addAddonInfoProvider(addonInfoProvider); + Set addons = addonSuggestionService.getSuggestedAddons(localeProvider.getLocale()); + assertEquals(2, addons.size()); + assertFalse(addons.stream().anyMatch(a -> "aardvark".equals(a.getUID()))); + assertTrue(addons.stream().anyMatch(a -> "binding-hue".equals(a.getUID()))); + assertTrue(addons.stream().anyMatch(a -> "binding-hpprinter".equals(a.getUID()))); + } +} diff --git a/bundles/org.openhab.core.config.discovery.mdns/pom.xml b/bundles/org.openhab.core.config.discovery.mdns/pom.xml index fafd855d6dd..f0ef9975b58 100644 --- a/bundles/org.openhab.core.config.discovery.mdns/pom.xml +++ b/bundles/org.openhab.core.config.discovery.mdns/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.config.discovery.mdns diff --git a/bundles/org.openhab.core.config.discovery.mdns/src/main/java/org/openhab/core/config/discovery/mdns/MDNSDiscoveryParticipant.java b/bundles/org.openhab.core.config.discovery.mdns/src/main/java/org/openhab/core/config/discovery/mdns/MDNSDiscoveryParticipant.java index 97a1a428e83..f9923a98902 100644 --- a/bundles/org.openhab.core.config.discovery.mdns/src/main/java/org/openhab/core/config/discovery/mdns/MDNSDiscoveryParticipant.java +++ b/bundles/org.openhab.core.config.discovery.mdns/src/main/java/org/openhab/core/config/discovery/mdns/MDNSDiscoveryParticipant.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery.mdns/src/main/java/org/openhab/core/config/discovery/mdns/internal/MDNSDiscoveryService.java b/bundles/org.openhab.core.config.discovery.mdns/src/main/java/org/openhab/core/config/discovery/mdns/internal/MDNSDiscoveryService.java index a6aba48a118..baa7de92859 100644 --- a/bundles/org.openhab.core.config.discovery.mdns/src/main/java/org/openhab/core/config/discovery/mdns/internal/MDNSDiscoveryService.java +++ b/bundles/org.openhab.core.config.discovery.mdns/src/main/java/org/openhab/core/config/discovery/mdns/internal/MDNSDiscoveryService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery.upnp/pom.xml b/bundles/org.openhab.core.config.discovery.upnp/pom.xml index 4c99a1bb0af..f8a71aad2bb 100644 --- a/bundles/org.openhab.core.config.discovery.upnp/pom.xml +++ b/bundles/org.openhab.core.config.discovery.upnp/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.config.discovery.upnp diff --git a/bundles/org.openhab.core.config.discovery.upnp/src/main/java/org/openhab/core/config/discovery/upnp/UpnpDiscoveryParticipant.java b/bundles/org.openhab.core.config.discovery.upnp/src/main/java/org/openhab/core/config/discovery/upnp/UpnpDiscoveryParticipant.java index 365bb7b5241..c2d299b0350 100644 --- a/bundles/org.openhab.core.config.discovery.upnp/src/main/java/org/openhab/core/config/discovery/upnp/UpnpDiscoveryParticipant.java +++ b/bundles/org.openhab.core.config.discovery.upnp/src/main/java/org/openhab/core/config/discovery/upnp/UpnpDiscoveryParticipant.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery.upnp/src/main/java/org/openhab/core/config/discovery/upnp/internal/UpnpDiscoveryService.java b/bundles/org.openhab.core.config.discovery.upnp/src/main/java/org/openhab/core/config/discovery/upnp/internal/UpnpDiscoveryService.java index e9f13bb600b..e196123b46e 100644 --- a/bundles/org.openhab.core.config.discovery.upnp/src/main/java/org/openhab/core/config/discovery/upnp/internal/UpnpDiscoveryService.java +++ b/bundles/org.openhab.core.config.discovery.upnp/src/main/java/org/openhab/core/config/discovery/upnp/internal/UpnpDiscoveryService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -24,6 +24,7 @@ import org.eclipse.jdt.annotation.Nullable; import org.jupnp.UpnpService; +import org.jupnp.model.message.header.RootDeviceHeader; import org.jupnp.model.meta.LocalDevice; import org.jupnp.model.meta.RemoteDevice; import org.jupnp.model.types.UDN; @@ -151,6 +152,7 @@ protected void startScan() { } upnpService.getRegistry().addListener(this); upnpService.getControlPoint().search(); + upnpService.getControlPoint().search(new RootDeviceHeader()); } @Override diff --git a/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/pom.xml b/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/pom.xml index a02f1b38fd8..b94212ddd9d 100644 --- a/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/pom.xml +++ b/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.config.discovery.usbserial.linuxsysfs diff --git a/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/DeltaUsbSerialScanner.java b/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/DeltaUsbSerialScanner.java index 193abf331a1..1fea291a4ec 100644 --- a/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/DeltaUsbSerialScanner.java +++ b/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/DeltaUsbSerialScanner.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -79,7 +79,7 @@ private Set setDifference(Set set1, Set set2) { /** * Delta between two subsequent scan results. */ - class Delta { + static class Delta { private final Set added; private final Set removed; diff --git a/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/PollingUsbSerialScanner.java b/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/PollingUsbSerialScanner.java index 9fee6585242..1ca831f303b 100644 --- a/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/PollingUsbSerialScanner.java +++ b/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/PollingUsbSerialScanner.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/SysfsUsbSerialScanner.java b/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/SysfsUsbSerialScanner.java index 88c34ad756e..50483ab0627 100644 --- a/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/SysfsUsbSerialScanner.java +++ b/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/SysfsUsbSerialScanner.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -289,16 +289,14 @@ private void extractConfiguration(Map config) { } if (!canPerformScans()) { - String logString = String.format( - "Cannot perform scans with this configuration: sysfsTtyDevicesDirectory: {}, devDirectory: {}", - sysfsTtyDevicesDirectory, devDirectory); + String message = "Cannot perform scans with this configuration: sysfsTtyDevicesDirectory: {}, devDirectory: {}"; if (configurationIsChanged) { // Warn if the configuration was actively changed - logger.warn(logString); + logger.warn(message, sysfsTtyDevicesDirectory, devDirectory); } else { // Otherwise, only debug log - so that, in particular, on Non-Linux systems users do not see warning - logger.debug(logString); + logger.debug(message, sysfsTtyDevicesDirectory, devDirectory); } } } diff --git a/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/UsbSerialScanner.java b/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/UsbSerialScanner.java index 37ac967d073..d5dc36f4da1 100644 --- a/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/UsbSerialScanner.java +++ b/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/UsbSerialScanner.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery.usbserial.ser2net/pom.xml b/bundles/org.openhab.core.config.discovery.usbserial.ser2net/pom.xml index ba0ed4a962e..0d7b22e038a 100644 --- a/bundles/org.openhab.core.config.discovery.usbserial.ser2net/pom.xml +++ b/bundles/org.openhab.core.config.discovery.usbserial.ser2net/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.config.discovery.usbserial.ser2net diff --git a/bundles/org.openhab.core.config.discovery.usbserial.ser2net/src/main/java/org/openhab/core/config/discovery/usbserial/ser2net/internal/Ser2NetUsbSerialDiscovery.java b/bundles/org.openhab.core.config.discovery.usbserial.ser2net/src/main/java/org/openhab/core/config/discovery/usbserial/ser2net/internal/Ser2NetUsbSerialDiscovery.java index c7a17b0d2b6..da6e87eb38f 100644 --- a/bundles/org.openhab.core.config.discovery.usbserial.ser2net/src/main/java/org/openhab/core/config/discovery/usbserial/ser2net/internal/Ser2NetUsbSerialDiscovery.java +++ b/bundles/org.openhab.core.config.discovery.usbserial.ser2net/src/main/java/org/openhab/core/config/discovery/usbserial/ser2net/internal/Ser2NetUsbSerialDiscovery.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -125,9 +125,9 @@ public synchronized void doSingleScan() { lastScanResult = scanResult; - removed.stream().forEach(this::announceRemovedDevice); - added.stream().forEach(this::announceAddedDevice); - unchanged.stream().forEach(this::announceAddedDevice); + removed.forEach(this::announceRemovedDevice); + added.forEach(this::announceAddedDevice); + unchanged.forEach(this::announceAddedDevice); logger.debug("Completed ser2net USB-Serial mDNS single discovery scan"); } @@ -198,7 +198,8 @@ private Optional createUsbSerialDeviceInformation(Se serviceInfo.getPort()); UsbSerialDeviceInformation deviceInfo = new UsbSerialDeviceInformation(vendorId, productId, serialNumber, - manufacturer, product, interfaceNumber, interfaceDescription, serialPortName); + manufacturer, product, interfaceNumber, interfaceDescription, serialPortName).setRemote(true); + logger.debug("Created {} based on {}", deviceInfo, serviceInfo); return Optional.of(deviceInfo); } catch (NumberFormatException e) { diff --git a/bundles/org.openhab.core.config.discovery.usbserial.ser2net/src/test/java/org/openhab/core/config/discovery/usbserial/ser2net/internal/Ser2NetUsbSerialDiscoveryTest.java b/bundles/org.openhab.core.config.discovery.usbserial.ser2net/src/test/java/org/openhab/core/config/discovery/usbserial/ser2net/internal/Ser2NetUsbSerialDiscoveryTest.java index 48dae85d310..57387d1c7b9 100644 --- a/bundles/org.openhab.core.config.discovery.usbserial.ser2net/src/test/java/org/openhab/core/config/discovery/usbserial/ser2net/internal/Ser2NetUsbSerialDiscoveryTest.java +++ b/bundles/org.openhab.core.config.discovery.usbserial.ser2net/src/test/java/org/openhab/core/config/discovery/usbserial/ser2net/internal/Ser2NetUsbSerialDiscoveryTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,11 +61,11 @@ public class Ser2NetUsbSerialDiscoveryTest { private @NonNullByDefault({}) Ser2NetUsbSerialDiscovery discovery; private UsbSerialDeviceInformation usb1 = new UsbSerialDeviceInformation(0x100, 0x111, "serial1", "manufacturer1", - "product1", 0x1, "interface1", "rfc2217://1.1.1.1:1000"); + "product1", 0x1, "interface1", "rfc2217://1.1.1.1:1000").setRemote(true); private UsbSerialDeviceInformation usb2 = new UsbSerialDeviceInformation(0x200, 0x222, "serial2", "manufacturer2", - "product2", 0x2, "interface2", "rfc2217://[0:0:0:0:0:ffff:0202:0202]:2222"); + "product2", 0x2, "interface2", "rfc2217://[0:0:0:0:0:ffff:0202:0202]:2222").setRemote(true); private UsbSerialDeviceInformation usb3 = new UsbSerialDeviceInformation(0x300, 0x333, null, null, null, 0x3, null, - "rfc2217://123.222.100.000:3030"); + "rfc2217://123.222.100.000:3030").setRemote(true); @BeforeEach public void beforeEach() { diff --git a/bundles/org.openhab.core.config.discovery.usbserial.windowsregistry/.classpath b/bundles/org.openhab.core.config.discovery.usbserial.windowsregistry/.classpath new file mode 100644 index 00000000000..58cd399d639 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.usbserial.windowsregistry/.classpath @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.openhab.core.config.discovery.usbserial.windowsregistry/.project b/bundles/org.openhab.core.config.discovery.usbserial.windowsregistry/.project new file mode 100644 index 00000000000..ad2f4ec236a --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.usbserial.windowsregistry/.project @@ -0,0 +1,23 @@ + + + org.openhab.core.config.discovery.usbserial.javaxusb + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/bundles/org.openhab.core.config.discovery.usbserial.windowsregistry/NOTICE b/bundles/org.openhab.core.config.discovery.usbserial.windowsregistry/NOTICE new file mode 100644 index 00000000000..6c17d0d8a45 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.usbserial.windowsregistry/NOTICE @@ -0,0 +1,14 @@ +This content is produced and maintained by the openHAB project. + +* Project home: https://www.openhab.org + +== Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License 2.0 which is available at +https://www.eclipse.org/legal/epl-2.0/. + +== Source Code + +https://github.com/openhab/openhab-core + diff --git a/bundles/org.openhab.core.config.discovery.usbserial.windowsregistry/pom.xml b/bundles/org.openhab.core.config.discovery.usbserial.windowsregistry/pom.xml new file mode 100644 index 00000000000..59a092e7d41 --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.usbserial.windowsregistry/pom.xml @@ -0,0 +1,30 @@ + + + + 4.0.0 + + + org.openhab.core.bundles + org.openhab.core.reactor.bundles + 4.2.0-SNAPSHOT + + + org.openhab.core.config.discovery.usbserial.windowsregistry + + openHAB Core :: Bundles :: Configuration USB-Serial Discovery for Windows + + + + org.openhab.core.bundles + org.openhab.core.config.discovery.usbserial + ${project.version} + + + net.java.dev.jna + jna-platform + 5.13.0 + + + + diff --git a/bundles/org.openhab.core.config.discovery.usbserial.windowsregistry/src/main/java/org/openhab/core/config/discovery/usbserial/windowsregistry/internal/WindowsUsbSerialDiscovery.java b/bundles/org.openhab.core.config.discovery.usbserial.windowsregistry/src/main/java/org/openhab/core/config/discovery/usbserial/windowsregistry/internal/WindowsUsbSerialDiscovery.java new file mode 100644 index 00000000000..5c19cd089cc --- /dev/null +++ b/bundles/org.openhab.core.config.discovery.usbserial.windowsregistry/src/main/java/org/openhab/core/config/discovery/usbserial/windowsregistry/internal/WindowsUsbSerialDiscovery.java @@ -0,0 +1,261 @@ +/** + * 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.config.discovery.usbserial.windowsregistry.internal; + +import static com.sun.jna.platform.win32.WinReg.HKEY_LOCAL_MACHINE; + +import java.time.Duration; +import java.util.HashSet; +import java.util.Map.Entry; +import java.util.Set; +import java.util.TreeMap; +import java.util.concurrent.CopyOnWriteArraySet; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.core.common.ThreadFactoryBuilder; +import org.openhab.core.config.discovery.usbserial.UsbSerialDeviceInformation; +import org.openhab.core.config.discovery.usbserial.UsbSerialDiscovery; +import org.openhab.core.config.discovery.usbserial.UsbSerialDiscoveryListener; +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.sun.jna.Platform; +import com.sun.jna.platform.win32.Advapi32Util; + +/** + * This is a {@link UsbSerialDiscovery} implementation component for Windows. + * It parses the Windows registry for USB device entries. + * + * @author Andrew Fiddian-Green - Initial contribution + */ +@NonNullByDefault +@Component(service = UsbSerialDiscovery.class, name = WindowsUsbSerialDiscovery.SERVICE_NAME) +public class WindowsUsbSerialDiscovery implements UsbSerialDiscovery { + + protected static final String SERVICE_NAME = "usb-serial-discovery-windows"; + + // registry accessor strings + private static final String USB_REGISTRY_ROOT = "SYSTEM\\CurrentControlSet\\Enum\\USB"; + private static final String BACKSLASH = "\\"; + private static final String PREFIX_PID = "PID_"; + private static final String PREFIX_VID = "VID_"; + private static final String PREFIX_HEX = "0x"; + private static final String SPLIT_IDS = "&"; + private static final String SPLIT_VALUES = ";"; + private static final String KEY_MANUFACTURER = "Mfg"; + private static final String KEY_PRODUCT = "DeviceDesc"; + private static final String KEY_DEVICE_PARAMETERS = "Device Parameters"; + private static final String KEY_SERIAL_PORT = "PortName"; + + private final Logger logger = LoggerFactory.getLogger(WindowsUsbSerialDiscovery.class); + private final Set discoveryListeners = new CopyOnWriteArraySet<>(); + private final Duration scanInterval = Duration.ofSeconds(15); + private final ScheduledExecutorService scheduler; + + private Set lastScanResult = new HashSet<>(); + private @Nullable ScheduledFuture scanTask; + + @Activate + public WindowsUsbSerialDiscovery() { + scheduler = Executors.newSingleThreadScheduledExecutor( + ThreadFactoryBuilder.create().withName(SERVICE_NAME).withDaemonThreads(true).build()); + } + + private void announceAddedDevice(UsbSerialDeviceInformation deviceInfo) { + for (UsbSerialDiscoveryListener listener : discoveryListeners) { + listener.usbSerialDeviceDiscovered(deviceInfo); + } + } + + private void announceRemovedDevice(UsbSerialDeviceInformation deviceInfo) { + for (UsbSerialDiscoveryListener listener : discoveryListeners) { + listener.usbSerialDeviceRemoved(deviceInfo); + } + } + + @Deactivate + public void deactivate() { + stopBackgroundScanning(); + lastScanResult.clear(); + } + + @Override + public synchronized void doSingleScan() { + Set scanResult = scanAllUsbDevicesInformation(); + Set added = setDifference(scanResult, lastScanResult); + Set removed = setDifference(lastScanResult, scanResult); + Set unchanged = setDifference(scanResult, added); + + lastScanResult = scanResult; + + removed.forEach(this::announceRemovedDevice); + added.forEach(this::announceAddedDevice); + unchanged.forEach(this::announceAddedDevice); + } + + private Set setDifference(Set set1, Set set2) { + Set result = new HashSet<>(set1); + result.removeAll(set2); + return result; + } + + @Override + public void registerDiscoveryListener(UsbSerialDiscoveryListener listener) { + discoveryListeners.add(listener); + for (UsbSerialDeviceInformation deviceInfo : lastScanResult) { + listener.usbSerialDeviceDiscovered(deviceInfo); + } + } + + @Override + public void unregisterDiscoveryListener(UsbSerialDiscoveryListener listener) { + discoveryListeners.remove(listener); + } + + /** + * Traverse the USB tree in Windows registry and return a set of USB device information. + * + * @return a set of USB device information. + */ + public Set scanAllUsbDevicesInformation() { + if (!Platform.isWindows()) { + return Set.of(); + } + + Set result = new HashSet<>(); + String[] deviceKeys = Advapi32Util.registryGetKeys(HKEY_LOCAL_MACHINE, USB_REGISTRY_ROOT); + + for (String deviceKey : deviceKeys) { + logger.trace("{}", deviceKey); + + if (!deviceKey.startsWith(PREFIX_VID)) { + continue; + } + + String[] ids = deviceKey.split(SPLIT_IDS); + if (ids.length < 2) { + continue; + } + + if (!ids[1].startsWith(PREFIX_PID)) { + continue; + } + + int vendorId; + int productId; + try { + vendorId = Integer.decode(PREFIX_HEX + ids[0].substring(4)); + productId = Integer.decode(PREFIX_HEX + ids[1].substring(4)); + } catch (NumberFormatException e) { + continue; + } + + String serialNumber = ids.length > 2 ? ids[2] : null; + + String devicePath = USB_REGISTRY_ROOT + BACKSLASH + deviceKey; + String[] interfaceNames = Advapi32Util.registryGetKeys(HKEY_LOCAL_MACHINE, devicePath); + + int interfaceId = 0; + for (String interfaceName : interfaceNames) { + logger.trace(" interfaceId:{}, interfaceName:{}", interfaceId, interfaceName); + + String interfacePath = devicePath + BACKSLASH + interfaceName; + TreeMap values = Advapi32Util.registryGetValues(HKEY_LOCAL_MACHINE, interfacePath); + + if (logger.isTraceEnabled()) { + for (Entry value : values.entrySet()) { + logger.trace(" {}={}", value.getKey(), value.getValue()); + } + } + + String manufacturer; + Object manufacturerValue = values.get(KEY_MANUFACTURER); + if (manufacturerValue instanceof String manufacturerString) { + String[] manufacturerData = manufacturerString.split(SPLIT_VALUES); + if (manufacturerData.length < 2) { + continue; + } + manufacturer = manufacturerData[1]; + } else { + continue; + } + + String product; + Object productValue = values.get(KEY_PRODUCT); + if (productValue instanceof String productString) { + String[] productData = productString.split(SPLIT_VALUES); + if (productData.length < 2) { + continue; + } + product = productData[1]; + } else { + continue; + } + + String serialPort = ""; + String[] interfaceSubKeys = Advapi32Util.registryGetKeys(HKEY_LOCAL_MACHINE, interfacePath); + + for (String interfaceSubKey : interfaceSubKeys) { + if (!KEY_DEVICE_PARAMETERS.equals(interfaceSubKey)) { + continue; + } + String deviceParametersPath = interfacePath + BACKSLASH + interfaceSubKey; + TreeMap deviceParameterValues = Advapi32Util.registryGetValues(HKEY_LOCAL_MACHINE, + deviceParametersPath); + Object serialPortValue = deviceParameterValues.get(KEY_SERIAL_PORT); + if (serialPortValue instanceof String serialPortString) { + serialPort = serialPortString; + } + break; + } + + UsbSerialDeviceInformation usbSerialDeviceInformation = new UsbSerialDeviceInformation(vendorId, + productId, serialNumber, manufacturer, product, interfaceId, interfaceName, serialPort); + + logger.debug("Add {}", usbSerialDeviceInformation); + result.add(usbSerialDeviceInformation); + + interfaceId++; + } + } + return result; + } + + @Override + public synchronized void startBackgroundScanning() { + if (Platform.isWindows()) { + ScheduledFuture scanTask = this.scanTask; + if (scanTask == null || scanTask.isDone()) { + this.scanTask = scheduler.scheduleWithFixedDelay(this::doSingleScan, 0, scanInterval.toSeconds(), + TimeUnit.SECONDS); + } + } + } + + @Override + public synchronized void stopBackgroundScanning() { + ScheduledFuture scanTask = this.scanTask; + if (scanTask != null) { + scanTask.cancel(false); + } + this.scanTask = null; + } +} diff --git a/bundles/org.openhab.core.config.discovery.usbserial/pom.xml b/bundles/org.openhab.core.config.discovery.usbserial/pom.xml index b8b957e21fa..44a0f843484 100644 --- a/bundles/org.openhab.core.config.discovery.usbserial/pom.xml +++ b/bundles/org.openhab.core.config.discovery.usbserial/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.config.discovery.usbserial diff --git a/bundles/org.openhab.core.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/UsbSerialDeviceInformation.java b/bundles/org.openhab.core.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/UsbSerialDeviceInformation.java index 60ed8b2714d..ba42bd5f03b 100644 --- a/bundles/org.openhab.core.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/UsbSerialDeviceInformation.java +++ b/bundles/org.openhab.core.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/UsbSerialDeviceInformation.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -45,11 +45,13 @@ public class UsbSerialDeviceInformation { private final String serialPort; + private boolean remote = false; + public UsbSerialDeviceInformation(int vendorId, int productId, @Nullable String serialNumber, @Nullable String manufacturer, @Nullable String product, int interfaceNumber, @Nullable String interfaceDescription, String serialPort) { - this.vendorId = requireNonNull(vendorId); - this.productId = requireNonNull(productId); + this.vendorId = vendorId; + this.productId = productId; this.serialNumber = serialNumber; this.manufacturer = manufacturer; @@ -118,6 +120,21 @@ public String getSerialPort() { return serialPort; } + /** + * @return if the serial device is remote or local. + */ + public boolean getRemote() { + return remote; + } + + /** + * Set the remote flag + */ + public UsbSerialDeviceInformation setRemote(boolean remote) { + this.remote = remote; + return this; + } + @SuppressWarnings("null") @Override public int hashCode() { @@ -131,6 +148,7 @@ public int hashCode() { result = prime * result + ((product == null) ? 0 : product.hashCode()); result = prime * result + ((serialNumber == null) ? 0 : serialNumber.hashCode()); result = prime * result + ((interfaceDescription == null) ? 0 : interfaceDescription.hashCode()); + result = prime * result + (remote ? 1 : 0); return result; } @@ -180,6 +198,10 @@ public boolean equals(@Nullable Object obj) { return false; } + if (remote != other.remote) { + return false; + } + return true; } @@ -187,8 +209,8 @@ public boolean equals(@Nullable Object obj) { public String toString() { return String.format( "UsbSerialDeviceInformation [vendorId=0x%04X, productId=0x%04X, serialNumber=%s, manufacturer=%s, " - + "product=%s, interfaceNumber=0x%02X, interfaceDescription=%s, serialPort=%s]", + + "product=%s, interfaceNumber=0x%02X, interfaceDescription=%s, serialPort=%s, remote=%b]", vendorId, productId, serialNumber, manufacturer, product, interfaceNumber, interfaceDescription, - serialPort); + serialPort, remote); } } diff --git a/bundles/org.openhab.core.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/UsbSerialDiscovery.java b/bundles/org.openhab.core.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/UsbSerialDiscovery.java index f6e85a5114b..f73f6da1720 100644 --- a/bundles/org.openhab.core.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/UsbSerialDiscovery.java +++ b/bundles/org.openhab.core.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/UsbSerialDiscovery.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/UsbSerialDiscoveryListener.java b/bundles/org.openhab.core.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/UsbSerialDiscoveryListener.java index fc06cc8c7c9..d0e17ce5d13 100644 --- a/bundles/org.openhab.core.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/UsbSerialDiscoveryListener.java +++ b/bundles/org.openhab.core.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/UsbSerialDiscoveryListener.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/UsbSerialDiscoveryParticipant.java b/bundles/org.openhab.core.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/UsbSerialDiscoveryParticipant.java index d9c68ee69f5..97fe94d0c1b 100644 --- a/bundles/org.openhab.core.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/UsbSerialDiscoveryParticipant.java +++ b/bundles/org.openhab.core.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/UsbSerialDiscoveryParticipant.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/internal/UsbSerialDiscoveryService.java b/bundles/org.openhab.core.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/internal/UsbSerialDiscoveryService.java index abe67b44e6d..4f3f63dfc4b 100644 --- a/bundles/org.openhab.core.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/internal/UsbSerialDiscoveryService.java +++ b/bundles/org.openhab.core.config.discovery.usbserial/src/main/java/org/openhab/core/config/discovery/usbserial/internal/UsbSerialDiscoveryService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery/pom.xml b/bundles/org.openhab.core.config.discovery/pom.xml index a3753c11e73..17dd511021f 100644 --- a/bundles/org.openhab.core.config.discovery/pom.xml +++ b/bundles/org.openhab.core.config.discovery/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.config.discovery diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/AbstractDiscoveryService.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/AbstractDiscoveryService.java index 4427b84bec6..0f980bdb6e7 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/AbstractDiscoveryService.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/AbstractDiscoveryService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,9 +12,9 @@ */ package org.openhab.core.config.discovery; +import java.time.Instant; import java.util.Arrays; import java.util.Collection; -import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -27,6 +27,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.common.ThreadPoolManager; +import org.openhab.core.config.core.ConfigParser; import org.openhab.core.i18n.I18nUtil; import org.openhab.core.i18n.LocaleProvider; import org.openhab.core.i18n.TranslationProvider; @@ -68,7 +69,7 @@ public abstract class AbstractDiscoveryService implements DiscoveryService { private final Set supportedThingTypes; private final int timeout; - private long timestampOfLastScan = 0L; + private Instant timestampOfLastScan = Instant.MIN; private @Nullable ScheduledFuture scheduledStop; @@ -85,7 +86,7 @@ public abstract class AbstractDiscoveryService implements DiscoveryService { * enable background discovery or not. * @throws IllegalArgumentException if {@code timeout < 0} */ - public AbstractDiscoveryService(@Nullable Set supportedThingTypes, int timeout, + protected AbstractDiscoveryService(@Nullable Set supportedThingTypes, int timeout, boolean backgroundDiscoveryEnabledByDefault) throws IllegalArgumentException { if (timeout < 0) { throw new IllegalArgumentException("The timeout must be >= 0!"); @@ -104,7 +105,7 @@ public AbstractDiscoveryService(@Nullable Set supportedThingTypes, * If set to 0, disables the automatic stop. * @throws IllegalArgumentException if {@code timeout < 0} */ - public AbstractDiscoveryService(@Nullable Set supportedThingTypes, int timeout) + protected AbstractDiscoveryService(@Nullable Set supportedThingTypes, int timeout) throws IllegalArgumentException { this(supportedThingTypes, timeout, true); } @@ -117,7 +118,7 @@ public AbstractDiscoveryService(@Nullable Set supportedThingTypes, * If set to 0, disables the automatic stop. * @throws IllegalArgumentException if {@code timeout < 0} */ - public AbstractDiscoveryService(int timeout) throws IllegalArgumentException { + protected AbstractDiscoveryService(int timeout) throws IllegalArgumentException { this(null, timeout); } @@ -172,9 +173,10 @@ public synchronized void startScan(@Nullable ScanListener listener) { // we first stop any currently running scan and its scheduled stop // call stopScan(); + ScheduledFuture scheduledStop = this.scheduledStop; if (scheduledStop != null) { scheduledStop.cancel(false); - scheduledStop = null; + this.scheduledStop = null; } scanListener = listener; @@ -189,14 +191,15 @@ public synchronized void startScan(@Nullable ScanListener listener) { } }, getScanTimeout(), TimeUnit.SECONDS); } - timestampOfLastScan = new Date().getTime(); + timestampOfLastScan = Instant.now(); try { startScan(); } catch (Exception ex) { + scheduledStop = this.scheduledStop; if (scheduledStop != null) { scheduledStop.cancel(false); - scheduledStop = null; + this.scheduledStop = null; } scanListener = null; throw ex; @@ -207,9 +210,10 @@ public synchronized void startScan(@Nullable ScanListener listener) { @Override public synchronized void abortScan() { synchronized (this) { + ScheduledFuture scheduledStop = this.scheduledStop; if (scheduledStop != null) { scheduledStop.cancel(false); - scheduledStop = null; + this.scheduledStop = null; } final ScanListener scanListener = this.scanListener; if (scanListener != null) { @@ -232,9 +236,10 @@ public synchronized void abortScan() { * This method cleans up after a scan, i.e. it removes listeners and other required operations. */ protected synchronized void stopScan() { + ScanListener scanListener = this.scanListener; if (scanListener != null) { scanListener.onFinished(); - scanListener = null; + this.scanListener = null; } } @@ -347,10 +352,9 @@ protected void removeOlderResults(long timestamp, @Nullable Collection configProperties) { if (configProperties != null) { - Object property = configProperties.get(DiscoveryService.CONFIG_PROPERTY_BACKGROUND_DISCOVERY); - if (property != null) { - backgroundDiscoveryEnabled = getAutoDiscoveryEnabled(property); - } + backgroundDiscoveryEnabled = ConfigParser.valueAsOrElse( + configProperties.get(DiscoveryService.CONFIG_PROPERTY_BACKGROUND_DISCOVERY), Boolean.class, + backgroundDiscoveryEnabled); } if (backgroundDiscoveryEnabled) { startBackgroundDiscovery(); @@ -370,20 +374,18 @@ protected void activate(@Nullable Map configProperties) { */ protected void modified(@Nullable Map configProperties) { if (configProperties != null) { - Object property = configProperties.get(DiscoveryService.CONFIG_PROPERTY_BACKGROUND_DISCOVERY); - if (property != null) { - boolean enabled = getAutoDiscoveryEnabled(property); - - if (backgroundDiscoveryEnabled && !enabled) { - stopBackgroundDiscovery(); - logger.debug("Background discovery for discovery service '{}' disabled.", - this.getClass().getName()); - } else if (!backgroundDiscoveryEnabled && enabled) { - startBackgroundDiscovery(); - logger.debug("Background discovery for discovery service '{}' enabled.", this.getClass().getName()); - } - backgroundDiscoveryEnabled = enabled; + boolean enabled = ConfigParser.valueAsOrElse( + configProperties.get(DiscoveryService.CONFIG_PROPERTY_BACKGROUND_DISCOVERY), Boolean.class, + backgroundDiscoveryEnabled); + + if (backgroundDiscoveryEnabled && !enabled) { + stopBackgroundDiscovery(); + logger.debug("Background discovery for discovery service '{}' disabled.", this.getClass().getName()); + } else if (!backgroundDiscoveryEnabled && enabled) { + startBackgroundDiscovery(); + logger.debug("Background discovery for discovery service '{}' enabled.", this.getClass().getName()); } + backgroundDiscoveryEnabled = enabled; } } @@ -423,15 +425,7 @@ protected void stopBackgroundDiscovery() { * @return timestamp as long */ protected long getTimestampOfLastScan() { - return timestampOfLastScan; - } - - private boolean getAutoDiscoveryEnabled(Object autoDiscoveryEnabled) { - if (autoDiscoveryEnabled instanceof String string) { - return Boolean.valueOf(string); - } else { - return Boolean.TRUE.equals(autoDiscoveryEnabled); - } + return Instant.MIN.equals(timestampOfLastScan) ? 0 : timestampOfLastScan.toEpochMilli(); } private String inferKey(DiscoveryResult discoveryResult, String lastSegment) { @@ -467,7 +461,7 @@ protected DiscoveryResult getLocalizedDiscoveryResult(final DiscoveryResult disc /** * Utility class to parse the key with parameters into the key and optional arguments. */ - private final class ParsedKey { + private static final class ParsedKey { private static final int LIMIT = 2; @@ -481,8 +475,8 @@ private ParsedKey(String label) { if (parts.length == 1) { this.args = null; } else { - this.args = Arrays.stream(parts[1].replaceAll("\\[|\\]|\"", "").split(",")) - .filter(s -> s != null && !s.isBlank()).map(s -> s.trim()).toArray(Object[]::new); + this.args = Arrays.stream(parts[1].replaceAll("\\[|\\]|\"", "").split(",")).filter(s -> !s.isBlank()) + .map(String::trim).toArray(Object[]::new); } } } diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/AbstractThingHandlerDiscoveryService.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/AbstractThingHandlerDiscoveryService.java new file mode 100644 index 00000000000..377c8e62fdf --- /dev/null +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/AbstractThingHandlerDiscoveryService.java @@ -0,0 +1,129 @@ +/** + * 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.config.discovery; + +import java.util.Map; +import java.util.Set; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.core.config.core.ConfigParser; +import org.openhab.core.thing.ThingTypeUID; +import org.openhab.core.thing.binding.ThingHandler; +import org.openhab.core.thing.binding.ThingHandlerService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The {@link AbstractThingHandlerDiscoveryService} extends the {@link AbstractDiscoveryService} for thing-based + * discovery services. + * + * It handles the injection of the {@link ThingHandler} + * + * @author Jan N. Klug - Initial contribution + */ +@NonNullByDefault +public abstract class AbstractThingHandlerDiscoveryService extends AbstractDiscoveryService + implements ThingHandlerService { + private final Logger logger = LoggerFactory.getLogger(AbstractThingHandlerDiscoveryService.class); + private final Class thingClazz; + private boolean backgroundDiscoveryEnabled = false; + + // this works around a bug in ecj: @NonNullByDefault({}) complains about the field not being + // initialized when the type is generic, so we have to initialize it with "something" + protected @NonNullByDefault({}) T thingHandler = (@NonNull T) null; + + protected AbstractThingHandlerDiscoveryService(Class thingClazz, @Nullable Set supportedThingTypes, + int timeout, boolean backgroundDiscoveryEnabledByDefault) throws IllegalArgumentException { + super(supportedThingTypes, timeout, backgroundDiscoveryEnabledByDefault); + this.thingClazz = thingClazz; + } + + protected AbstractThingHandlerDiscoveryService(Class thingClazz, @Nullable Set supportedThingTypes, + int timeout) throws IllegalArgumentException { + super(supportedThingTypes, timeout); + this.thingClazz = thingClazz; + } + + protected AbstractThingHandlerDiscoveryService(Class thingClazz, int timeout) throws IllegalArgumentException { + super(timeout); + this.thingClazz = thingClazz; + } + + @Override + protected abstract void startScan(); + + @Override + @SuppressWarnings("unchecked") + public void setThingHandler(ThingHandler handler) { + if (thingClazz.isAssignableFrom(handler.getClass())) { + this.thingHandler = (T) handler; + } else { + throw new IllegalArgumentException( + "Expected class is " + thingClazz + " but the parameter has class " + handler.getClass()); + } + } + + @Override + public @Nullable ThingHandler getThingHandler() { + return thingHandler; + } + + @Override + public void activate(@Nullable Map config) { + // do not call super.activate here, otherwise the scan might be background scan might be started before the + // thing handler is set. This is correctly handled in initialize + if (config != null) { + backgroundDiscoveryEnabled = ConfigParser.valueAsOrElse( + config.get(DiscoveryService.CONFIG_PROPERTY_BACKGROUND_DISCOVERY), Boolean.class, false); + } + } + + @Override + public void modified(@Nullable Map config) { + if (config != null) { + boolean enabled = ConfigParser.valueAsOrElse( + config.get(DiscoveryService.CONFIG_PROPERTY_BACKGROUND_DISCOVERY), Boolean.class, false); + + if (backgroundDiscoveryEnabled && !enabled) { + stopBackgroundDiscovery(); + logger.debug("Background discovery for discovery service '{}' disabled.", getClass().getName()); + } else if (!backgroundDiscoveryEnabled && enabled) { + startBackgroundDiscovery(); + logger.debug("Background discovery for discovery service '{}' enabled.", getClass().getName()); + } + backgroundDiscoveryEnabled = enabled; + } + } + + @Override + public void deactivate() { + // do not call super.deactivate here, background scan is already handled in dispose + } + + @Override + public void initialize() { + if (backgroundDiscoveryEnabled) { + startBackgroundDiscovery(); + logger.debug("Background discovery for discovery service '{}' enabled.", getClass().getName()); + } + } + + @Override + public void dispose() { + if (backgroundDiscoveryEnabled) { + stopBackgroundDiscovery(); + } + } +} diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryListener.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryListener.java index 3a9b6672424..b0ef4605eb4 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryListener.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryListener.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryResult.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryResult.java index 9cffecccdf7..38bd557dc10 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryResult.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryResult.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,8 +17,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; -import org.openhab.core.thing.Bridge; -import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.ThingUID; @@ -57,8 +55,8 @@ public interface DiscoveryResult { /** * Returns the unique {@code Thing} type ID of this result object. *

        - * A {@code Thing} type ID could be a product number which identifies the same type of {@link Thing}s. It's usually - * not a serial number. + * A {@code Thing} type ID could be a product number which identifies the same type of + * {@link org.openhab.core.thing.Thing}s. It's usually not a serial number. * * @return the unique Thing type */ @@ -115,7 +113,7 @@ public interface DiscoveryResult { String getLabel(); /** - * Returns the unique {@link Bridge} ID of this result object. + * Returns the unique {@link org.openhab.core.thing.Bridge} ID of this result object. * * @return the unique Bridge ID */ diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryResultBuilder.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryResultBuilder.java index c64dd0392f0..f3ab6891100 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryResultBuilder.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryResultBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +50,7 @@ public class DiscoveryResultBuilder { private DiscoveryResultBuilder(ThingUID thingUID) { this.thingUID = thingUID; - }; + } /** * Creates a new builder for a given thing UID. diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryResultFlag.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryResultFlag.java index 524c5ef400a..a53086a4463 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryResultFlag.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryResultFlag.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryService.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryService.java index 8d3f5058713..14eb273b9b9 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryService.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +50,7 @@ public interface DiscoveryService { * Configuration property for enabling the auto discovery feature of a * DiscoveryService. */ - static final String CONFIG_PROPERTY_BACKGROUND_DISCOVERY = "background"; + String CONFIG_PROPERTY_BACKGROUND_DISCOVERY = "background"; /** * Returns the list of {@code Thing} types which are supported by the {@link DiscoveryService}. diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryServiceRegistry.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryServiceRegistry.java index 29952247c02..19b6248d672 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryServiceRegistry.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/DiscoveryServiceRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery/src/main/java/org/openhab/core/config/discovery/ScanListener.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/ScanListener.java index 0d3cd618a59..2e06233f1ca 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/ScanListener.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/ScanListener.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery/src/main/java/org/openhab/core/config/discovery/dto/DiscoveryResultDTO.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/dto/DiscoveryResultDTO.java index e0ac9c40761..9aaf7f6aecc 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/dto/DiscoveryResultDTO.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/dto/DiscoveryResultDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery/src/main/java/org/openhab/core/config/discovery/dto/DiscoveryResultDTOMapper.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/dto/DiscoveryResultDTOMapper.java index 0d86364da6d..beb2859d62a 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/dto/DiscoveryResultDTOMapper.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/dto/DiscoveryResultDTOMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/Inbox.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/Inbox.java index 048e9e0be01..50ce3973cae 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/Inbox.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/Inbox.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -20,14 +20,12 @@ import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.config.discovery.DiscoveryResult; import org.openhab.core.config.discovery.DiscoveryResultFlag; -import org.openhab.core.config.discovery.DiscoveryService; import org.openhab.core.thing.Thing; -import org.openhab.core.thing.ThingRegistry; import org.openhab.core.thing.ThingUID; /** * The {@link Inbox} is a service interface providing a container for discovered {@code Thing}s - * (e.g. found by a {@link DiscoveryService}) as {@link DiscoveryResult}s. + * (e.g. found by a {@link org.openhab.core.config.discovery.DiscoveryService}) as {@link DiscoveryResult}s. *

        * A {@link DiscoveryResult} entry in this container is not a full configured {@code Thing} and therefore no * {@code Thing} exists for it. A {@link DiscoveryResult} can be marked to be ignored, so that a specific {@code Thing} @@ -126,7 +124,7 @@ public interface Inbox { void removeInboxListener(@Nullable InboxListener listener); /** - * Creates new {@link Thing} and adds it to the {@link ThingRegistry}. + * Creates new {@link Thing} and adds it to the {@link org.openhab.core.thing.ThingRegistry}. * * @param thingUID the UID of the Thing * @param label the label of the Thing diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/InboxAutoApprovePredicate.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/InboxAutoApprovePredicate.java index 37058f0dea4..ffa05007708 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/InboxAutoApprovePredicate.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/InboxAutoApprovePredicate.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,15 +16,14 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.config.discovery.DiscoveryResult; -import org.openhab.core.config.discovery.internal.AutomaticInboxProcessor; -import org.osgi.service.component.annotations.Component; /** - * {@link Component}s implementing this interface participate in the {@link AutomaticInboxProcessor}'s decision whether - * to automatically approve an inbox result or not. + * {@link org.osgi.service.component.annotations.Component}s implementing this interface participate in the + * {@link org.openhab.core.config.discovery.internal.AutomaticInboxProcessor}'s + * decision whether to automatically approve an inbox result or not. *

        * If this {@link Predicate} returns true the {@link DiscoveryResult} will be automatically approved by the - * {@link AutomaticInboxProcessor}. + * {@link org.openhab.core.config.discovery.internal.AutomaticInboxProcessor}. *

        * Note that if this {@link Predicate} returns false the {@link DiscoveryResult} might still be * automatically approved (e.g., because another such {@link Predicate} returned true) - i.e., it is not diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/InboxListener.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/InboxListener.java index 54cfd792563..60436db7e2b 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/InboxListener.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/InboxListener.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/InboxPredicates.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/InboxPredicates.java index 25bd1948b30..2f6dfa42bfb 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/InboxPredicates.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/InboxPredicates.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -47,7 +47,7 @@ public static Predicate withFlag(DiscoveryResultFlag flag) { public static Predicate withProperty(@Nullable String propertyName, String propertyValue) { return r -> r.getProperties().containsKey(propertyName) - && r.getProperties().get(propertyName).equals(propertyValue); + && propertyValue.equals(r.getProperties().get(propertyName)); } public static Predicate withRepresentationProperty(@Nullable String propertyName) { diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/AbstractInboxEvent.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/AbstractInboxEvent.java index 9ac68641690..6bba2a69521 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/AbstractInboxEvent.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/AbstractInboxEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,12 +14,12 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.config.discovery.dto.DiscoveryResultDTO; -import org.openhab.core.config.discovery.inbox.Inbox; import org.openhab.core.events.AbstractEvent; /** - * Abstract implementation of an inbox event which will be posted by the {@link Inbox} for added, removed - * and updated discovery results. + * Abstract implementation of an inbox event which will be posted by the + * {@link org.openhab.core.config.discovery.inbox.Inbox} + * for added, removed and updated discovery results. * * @author Stefan Bußweiler - Initial contribution */ @@ -35,7 +35,7 @@ public abstract class AbstractInboxEvent extends AbstractEvent { * @param payload the payload * @param discoveryResult the discovery-result data transfer object */ - public AbstractInboxEvent(String topic, String payload, DiscoveryResultDTO discoveryResult) { + protected AbstractInboxEvent(String topic, String payload, DiscoveryResultDTO discoveryResult) { super(topic, payload, null); this.discoveryResult = discoveryResult; } diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/InboxAddedEvent.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/InboxAddedEvent.java index f5d5811fc93..0880f2dfc6e 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/InboxAddedEvent.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/InboxAddedEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/InboxEventFactory.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/InboxEventFactory.java index 30552f1d6b5..9bc649e452d 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/InboxEventFactory.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/InboxEventFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/InboxRemovedEvent.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/InboxRemovedEvent.java index 005146cba7d..d038288974a 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/InboxRemovedEvent.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/InboxRemovedEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/InboxUpdatedEvent.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/InboxUpdatedEvent.java index 97d27a8f282..0afeec34f77 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/InboxUpdatedEvent.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/inbox/events/InboxUpdatedEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/AutomaticInboxProcessor.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/AutomaticInboxProcessor.java index 64a20ca37e8..7e285760311 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/AutomaticInboxProcessor.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/AutomaticInboxProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/DiscoveryResultImpl.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/DiscoveryResultImpl.java index 10ee61439cc..346a5878583 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/DiscoveryResultImpl.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/DiscoveryResultImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,8 +12,8 @@ */ package org.openhab.core.config.discovery.internal; +import java.time.Instant; import java.util.Collections; -import java.util.Date; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -22,9 +22,7 @@ import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.common.AbstractUID; import org.openhab.core.config.discovery.DiscoveryResult; -import org.openhab.core.config.discovery.DiscoveryResultBuilder; import org.openhab.core.config.discovery.DiscoveryResultFlag; -import org.openhab.core.thing.Bridge; import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.ThingUID; @@ -43,7 +41,7 @@ public class DiscoveryResultImpl implements DiscoveryResult { private @Nullable String representationProperty; private @NonNullByDefault({}) DiscoveryResultFlag flag; private @NonNullByDefault({}) String label; - private long timestamp; + private Instant timestamp = Instant.MIN; private long timeToLive = TTL_UNLIMITED; /** @@ -59,22 +57,19 @@ public class DiscoveryResultImpl implements DiscoveryResult { * @param thingUID the {@link ThingUID} to be set. If a {@code Thing} disappears and is discovered again, the same * {@code Thing} ID must be created. A typical {@code Thing} ID could be the serial number. It's usually * not a product name. - * @param bridgeUID the unique {@link Bridge} ID to be set + * @param bridgeUID the unique {@link org.openhab.core.thing.Bridge} ID to be set * @param properties the properties to be set * @param representationProperty the representationProperty to be set * @param label the human readable label to set * @param timeToLive time to live in seconds * * @throws IllegalArgumentException if the {@link ThingUID} is null or the time to live is less than 1 - * @deprecated use {@link DiscoveryResultBuilder} instead. + * @deprecated use {@link org.openhab.core.config.discovery.DiscoveryResultBuilder} instead. */ @Deprecated public DiscoveryResultImpl(@Nullable ThingTypeUID thingTypeUID, ThingUID thingUID, @Nullable ThingUID bridgeUID, @Nullable Map properties, @Nullable String representationProperty, @Nullable String label, long timeToLive) throws IllegalArgumentException { - if (thingUID == null) { - throw new IllegalArgumentException("The thing UID must not be null!"); - } if (timeToLive < 1 && timeToLive != TTL_UNLIMITED) { throw new IllegalArgumentException("The ttl must not be 0 or negative!"); } @@ -86,7 +81,7 @@ public DiscoveryResultImpl(@Nullable ThingTypeUID thingTypeUID, ThingUID thingUI this.representationProperty = representationProperty; this.label = label == null ? "" : label; - this.timestamp = new Date().getTime(); + this.timestamp = Instant.now(); this.timeToLive = timeToLive; this.flag = DiscoveryResultFlag.NEW; @@ -157,7 +152,7 @@ public void synchronize(@Nullable DiscoveryResult sourceResult) { this.properties = sourceResult.getProperties(); this.representationProperty = sourceResult.getRepresentationProperty(); this.label = sourceResult.getLabel(); - this.timestamp = new Date().getTime(); + this.timestamp = Instant.now(); this.timeToLive = sourceResult.getTimeToLive(); } } @@ -221,7 +216,7 @@ public String toString() { @Override public long getTimestamp() { - return timestamp; + return Instant.MIN.equals(timestamp) ? 0 : timestamp.toEpochMilli(); } @Override diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/DiscoveryServiceRegistryImpl.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/DiscoveryServiceRegistryImpl.java index 2f8d17d0e3a..25963f24c87 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/DiscoveryServiceRegistryImpl.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/DiscoveryServiceRegistryImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,6 +19,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.CancellationException; import java.util.concurrent.CopyOnWriteArraySet; @@ -84,6 +85,7 @@ public synchronized void onFinished() { logger.debug("Finished {} of {} discovery services.", finishedDiscoveryServices, numberOfDiscoveryServices); if (!errorOccurred && finishedDiscoveryServices == numberOfDiscoveryServices) { + ScanListener listener = this.listener; if (listener != null) { listener.onFinished(); } @@ -95,6 +97,7 @@ public synchronized void onFinished() { public void onErrorOccurred(@Nullable Exception exception) { synchronized (this) { if (!errorOccurred) { + ScanListener listener = this.listener; if (listener != null) { listener.onErrorOccurred(exception); } @@ -115,6 +118,7 @@ public void reduceNumberOfDiscoveryServices() { synchronized (this) { numberOfDiscoveryServices--; if (!errorOccurred && finishedDiscoveryServices == numberOfDiscoveryServices) { + ScanListener listener = this.listener; if (listener != null) { listener.onFinished(); } @@ -247,7 +251,7 @@ public synchronized void removeDiscoveryListener(DiscoveryListener listener) thr @Override public synchronized void thingDiscovered(final DiscoveryService source, final DiscoveryResult result) { synchronized (cachedResults) { - cachedResults.computeIfAbsent(source, unused -> new HashSet<>()).add(result); + Objects.requireNonNull(cachedResults.computeIfAbsent(source, unused -> new HashSet<>())).add(result); } for (final DiscoveryListener listener : listeners) { try { diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/PersistentInbox.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/PersistentInbox.java index 0730e3f3ccb..bc9e8c9c452 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/PersistentInbox.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/PersistentInbox.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,9 +15,9 @@ import static org.openhab.core.config.discovery.inbox.InboxPredicates.forThingUID; import java.net.URI; +import java.time.Instant; import java.util.ArrayList; import java.util.Collection; -import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -112,7 +112,7 @@ public TimeToLiveCheckingThread(PersistentInbox inbox) { @Override public void run() { - long now = new Date().getTime(); + Instant now = Instant.now(); for (DiscoveryResult result : inbox.getAll()) { if (isResultExpired(result, now)) { logger.debug("Inbox entry for thing '{}' is expired and will be removed.", result.getThingUID()); @@ -121,11 +121,12 @@ public void run() { } } - private boolean isResultExpired(DiscoveryResult result, long now) { - if (result.getTimeToLive() == DiscoveryResult.TTL_UNLIMITED) { + private boolean isResultExpired(DiscoveryResult result, Instant now) { + long ttl = result.getTimeToLive(); + if (ttl == DiscoveryResult.TTL_UNLIMITED) { return false; } - return (result.getTimestamp() + result.getTimeToLive() * 1000 < now); + return Instant.ofEpochMilli(result.getTimestamp()).plusSeconds(ttl).isBefore(now); } } @@ -184,9 +185,6 @@ protected void deactivate() { @Override public @Nullable Thing approve(ThingUID thingUID, @Nullable String label, @Nullable String newThingId) { - if (thingUID == null) { - throw new IllegalArgumentException("Thing UID must not be null"); - } List results = stream().filter(forThingUID(thingUID)).toList(); if (results.isEmpty()) { throw new IllegalArgumentException("No Thing with UID " + thingUID.getAsString() + " in inbox"); @@ -372,22 +370,7 @@ public List getAll() { @Override public Stream stream() { - final Storage discoveryResultStorage = this.discoveryResultStorage; - if (discoveryResultStorage == null) { - final ScheduledFuture timeToLiveChecker = this.timeToLiveChecker; - logger.error("The OSGi lifecycle has been violated (storage: {}, ttl checker cancelled: {}).", - this.discoveryResultStorage == null ? "null" : this.discoveryResultStorage, - timeToLiveChecker == null ? "null" : timeToLiveChecker.isCancelled()); - return Stream.empty(); - } - final Collection<@Nullable DiscoveryResult> values = discoveryResultStorage.getValues(); - if (values == null) { - logger.warn( - "The storage service violates the nullness requirements (get values must not return null) (storage class: {}).", - discoveryResultStorage.getClass()); - return Stream.empty(); - } - return (Stream) values.stream().filter(Objects::nonNull); + return (Stream) discoveryResultStorage.getValues().stream().filter(Objects::nonNull); } @Override @@ -442,7 +425,7 @@ public void thingRemoved(DiscoveryService source, ThingUID thingUID) { removedThings.add(thingUID); remove(thingUID); logger.debug("Removed thing '{}' from inbox because it was older than {}.", thingUID, - new Date(timestamp)); + Instant.ofEpochMilli(timestamp)); } } } @@ -496,10 +479,7 @@ public void setFlag(ThingUID thingUID, @Nullable DiscoveryResultFlag flag) { * null, if no discovery result could be found */ private @Nullable DiscoveryResult get(ThingUID thingUID) { - if (thingUID != null) { - return discoveryResultStorage.get(thingUID.toString()); - } - return null; + return discoveryResultStorage.get(thingUID.toString()); } private void notifyListeners(DiscoveryResult result, EventType type) { @@ -536,6 +516,7 @@ private void notifyListeners(DiscoveryResult result, EventType type) { } private void postEvent(DiscoveryResult result, EventType eventType) { + EventPublisher eventPublisher = this.eventPublisher; if (eventPublisher != null) { try { switch (eventType) { @@ -574,7 +555,7 @@ private void removeResultsForBridge(ThingUID bridgeUID) { private List getResultsForBridge(ThingUID bridgeUID) { List thingsForBridge = new ArrayList<>(); for (DiscoveryResult result : discoveryResultStorage.getValues()) { - if (bridgeUID.equals(result.getBridgeUID())) { + if (result != null && bridgeUID.equals(result.getBridgeUID())) { thingsForBridge.add(result.getThingUID()); } } @@ -608,10 +589,8 @@ private void getPropsAndConfigParams(final DiscoveryResult discoveryResult, fina private Set getConfigDescParamNames(List configDescParams) { Set paramNames = new HashSet<>(); - if (configDescParams != null) { - for (ConfigDescriptionParameter param : configDescParams) { - paramNames.add(param.getName()); - } + for (ConfigDescriptionParameter param : configDescParams) { + paramNames.add(param.getName()); } return paramNames; } diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/console/DiscoveryConsoleCommandExtension.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/console/DiscoveryConsoleCommandExtension.java index bca26910d47..31c98d7f8b2 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/console/DiscoveryConsoleCommandExtension.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/console/DiscoveryConsoleCommandExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/console/InboxConsoleCommandExtension.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/console/InboxConsoleCommandExtension.java index 74a9ded549c..270059ae8f2 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/console/InboxConsoleCommandExtension.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/openhab/core/config/discovery/internal/console/InboxConsoleCommandExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,17 +14,22 @@ import static org.openhab.core.config.discovery.inbox.InboxPredicates.*; -import java.util.Date; +import java.time.Instant; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.config.discovery.DiscoveryResult; import org.openhab.core.config.discovery.DiscoveryResultFlag; import org.openhab.core.config.discovery.inbox.Inbox; import org.openhab.core.config.discovery.internal.PersistentInbox; import org.openhab.core.io.console.Console; +import org.openhab.core.io.console.ConsoleCommandCompleter; +import org.openhab.core.io.console.StringsCompleter; import org.openhab.core.io.console.extensions.AbstractConsoleCommandExtension; import org.openhab.core.io.console.extensions.ConsoleCommandExtension; import org.openhab.core.thing.ThingTypeUID; @@ -50,8 +55,39 @@ public class InboxConsoleCommandExtension extends AbstractConsoleCommandExtensio private static final String SUBCMD_CLEAR = "clear"; private static final String SUBCMD_REMOVE = "remove"; + private static final StringsCompleter SUBCMD_COMPLETER = new StringsCompleter( + List.of(SUBCMD_APPROVE, SUBCMD_IGNORE, SUBCMD_LIST, SUBCMD_LIST_IGNORED, SUBCMD_CLEAR, SUBCMD_REMOVE), + false); + private final Inbox inbox; + private class InboxConsoleCommandCompleter implements ConsoleCommandCompleter { + @Override + public boolean complete(String[] args, int cursorArgumentIndex, int cursorPosition, List candidates) { + if (cursorArgumentIndex <= 0) { + return SUBCMD_COMPLETER.complete(args, cursorArgumentIndex, cursorPosition, candidates); + } else if (cursorArgumentIndex == 1) { + if (SUBCMD_IGNORE.equalsIgnoreCase(args[0]) || SUBCMD_APPROVE.equalsIgnoreCase(args[0])) { + return new StringsCompleter(getThingUIDs(), true).complete(args, cursorArgumentIndex, + cursorPosition, candidates); + } else if (SUBCMD_REMOVE.equalsIgnoreCase(args[0])) { + return new StringsCompleter(getThingAndThingTypeUIDs(), true).complete(args, cursorArgumentIndex, + cursorPosition, candidates); + } + } + return false; + } + + private Collection getThingUIDs() { + return inbox.stream().map(r -> r.getThingUID().getAsString()).toList(); + } + + private Collection getThingAndThingTypeUIDs() { + return inbox.stream() + .flatMap(r -> Stream.of(r.getThingUID().getAsString(), r.getThingTypeUID().getAsString())).toList(); + } + } + @Activate public InboxConsoleCommandExtension(final @Reference Inbox inbox) { super("inbox", "Manage your inbox."); @@ -163,7 +199,7 @@ private void printInboxEntries(Console console, List discoveryR ThingUID bridgeId = discoveryResult.getBridgeUID(); Map properties = discoveryResult.getProperties(); String representationProperty = discoveryResult.getRepresentationProperty(); - String timestamp = new Date(discoveryResult.getTimestamp()).toString(); + String timestamp = Instant.ofEpochMilli(discoveryResult.getTimestamp()).toString(); String timeToLive = discoveryResult.getTimeToLive() == DiscoveryResult.TTL_UNLIMITED ? "UNLIMITED" : "" + discoveryResult.getTimeToLive(); console.println(String.format( @@ -203,4 +239,9 @@ public List getUsages() { "remove the inbox entries of a given thing id or thing type"), buildCommandUsage(SUBCMD_IGNORE + " ", "ignores an inbox entry permanently")); } + + @Override + public @Nullable ConsoleCommandCompleter getCompleter() { + return new InboxConsoleCommandCompleter(); + } } diff --git a/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/AbstractDiscoveryServiceTest.java b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/AbstractDiscoveryServiceTest.java index f0e31c81b19..6e19183f784 100644 --- a/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/AbstractDiscoveryServiceTest.java +++ b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/AbstractDiscoveryServiceTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 @@ protected void startScan() { .build(); thingDiscovered(discoveryResult); } - }; + } @Override public void thingDiscovered(DiscoveryService source, DiscoveryResult result) { diff --git a/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/DiscoveryResultBuilderTest.java b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/DiscoveryResultBuilderTest.java index 1eade72fd01..d76cd230cfe 100644 --- a/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/DiscoveryResultBuilderTest.java +++ b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/DiscoveryResultBuilderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -56,6 +56,7 @@ public void setup() { discoveryResult = builder.build(); } + @Test public void testInstance() { assertThat(builder, is(instanceOf(DiscoveryResultBuilder.class))); assertThat(builder.withLabel("TEST"), is(instanceOf(DiscoveryResultBuilder.class))); diff --git a/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/inbox/InboxPredicatesTest.java b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/inbox/InboxPredicatesTest.java index b00e5771e12..42a94704bab 100644 --- a/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/inbox/InboxPredicatesTest.java +++ b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/inbox/InboxPredicatesTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery/src/test/java/org/openhab/core/config/discovery/inbox/events/InboxEventFactoryTest.java b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/inbox/events/InboxEventFactoryTest.java index 54fd9607355..eb233dbe2eb 100644 --- a/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/inbox/events/InboxEventFactoryTest.java +++ b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/inbox/events/InboxEventFactoryTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery/src/test/java/org/openhab/core/config/discovery/internal/AutomaticInboxProcessorTest.java b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/internal/AutomaticInboxProcessorTest.java index 5c2c091d343..7fa162ccea8 100644 --- a/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/internal/AutomaticInboxProcessorTest.java +++ b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/internal/AutomaticInboxProcessorTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.discovery/src/test/java/org/openhab/core/config/discovery/internal/DiscoveryResultImplTest.java b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/internal/DiscoveryResultImplTest.java index 96820449a80..6c5ca80e4eb 100644 --- a/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/internal/DiscoveryResultImplTest.java +++ b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/internal/DiscoveryResultImplTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,14 +18,14 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.junit.jupiter.api.Test; -import org.openhab.core.config.discovery.DiscoveryResult; import org.openhab.core.config.discovery.DiscoveryResultFlag; import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.ThingUID; /** * The {@link DiscoveryResultImplTest} checks if any invalid input parameters - * and the synchronization of {@link DiscoveryResult}s work in a correct way. + * and the synchronization of {@link org.openhab.core.config.discovery.DiscoveryResult}s + * work in a correct way. * * @author Michael Grammling - Initial contribution * @author Thomas Höfer - Added representation @@ -36,12 +36,14 @@ public class DiscoveryResultImplTest { private static final int DEFAULT_TTL = 60; + @SuppressWarnings("deprecation") @Test public void testInvalidConstructorForThingType() { assertThrows(IllegalArgumentException.class, () -> new DiscoveryResultImpl(null, new ThingUID("aa"), null, null, null, null, DEFAULT_TTL)); } + @SuppressWarnings("deprecation") @Test public void testInvalidConstructorForTTL() { ThingTypeUID thingTypeUID = new ThingTypeUID("bindingId", "thingType"); @@ -49,6 +51,7 @@ public void testInvalidConstructorForTTL() { new ThingUID(thingTypeUID, "thingId"), null, null, null, null, -2)); } + @SuppressWarnings("deprecation") @Test public void testValidConstructor() { ThingTypeUID thingTypeUID = new ThingTypeUID("bindingId", "thingType"); @@ -66,6 +69,7 @@ public void testValidConstructor() { assertNull(discoveryResult.getRepresentationProperty()); } + @SuppressWarnings("deprecation") @Test public void testInvalidSynchronize() { ThingTypeUID thingTypeUID = new ThingTypeUID("bindingId", "thingType"); @@ -85,6 +89,7 @@ public void testInvalidSynchronize() { assertEquals(DiscoveryResultFlag.IGNORED, discoveryResult.getFlag()); } + @SuppressWarnings("deprecation") @Test public void testIrrelevantSynchronize() { ThingTypeUID thingTypeUID = new ThingTypeUID("bindingId", "thingType"); @@ -107,6 +112,7 @@ public void testIrrelevantSynchronize() { assertEquals(DiscoveryResultFlag.IGNORED, discoveryResult.getFlag()); } + @SuppressWarnings("deprecation") @Test public void testSynchronize() { ThingTypeUID thingTypeUID = new ThingTypeUID("bindingId", "thingType"); @@ -135,6 +141,7 @@ public void testSynchronize() { assertEquals(DiscoveryResultFlag.IGNORED, discoveryResult.getFlag()); } + @SuppressWarnings("deprecation") @Test public void testThingTypeCompatibility() { ThingTypeUID thingTypeUID = new ThingTypeUID("bindingId", "thingType"); diff --git a/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/internal/PersistentInboxTest.java b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/internal/PersistentInboxTest.java index 32b2184b762..3d875ac3bf2 100644 --- a/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/internal/PersistentInboxTest.java +++ b/bundles/org.openhab.core.config.discovery/src/test/java/org/openhab/core/config/discovery/internal/PersistentInboxTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -114,12 +114,12 @@ public void testConfigUpdateNormalizationWithConfigDescription() throws URISynta when(thingRegistryMock.get(eq(THING_UID))).thenReturn(thing); when(thingProviderMock.get(eq(THING_UID))).thenReturn(thing); - assertTrue(thing.getConfiguration().get("foo") instanceof String); + assertInstanceOf(String.class, thing.getConfiguration().get("foo")); inbox.activate(); inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty("foo", 3).build()); - assertTrue(thing.getConfiguration().get("foo") instanceof String); + assertInstanceOf(String.class, thing.getConfiguration().get("foo")); // thing updated if managed assertEquals("3", thing.getConfiguration().get("foo")); } @@ -131,12 +131,12 @@ public void testConfigUpdateNormalizationWithConfigDescriptionUnanagedThing() { configureConfigDescriptionRegistryMock("foo", Type.TEXT); when(thingRegistryMock.get(eq(THING_UID))).thenReturn(thing); - assertTrue(thing.getConfiguration().get("foo") instanceof String); + assertInstanceOf(String.class, thing.getConfiguration().get("foo")); inbox.activate(); inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty("foo", 3).build()); - assertTrue(thing.getConfiguration().get("foo") instanceof String); + assertInstanceOf(String.class, thing.getConfiguration().get("foo")); // thing not updated if unmanaged assertEquals("1", thing.getConfiguration().get("foo")); } @@ -150,8 +150,10 @@ public void testApproveNormalization() { inbox.activate(); inbox.approve(THING_UID, "Test", null); + Thing lastAddedThing = this.lastAddedThing; + assertNotNull(lastAddedThing); assertEquals(THING_UID, lastAddedThing.getUID()); - assertTrue(lastAddedThing.getConfiguration().get("foo") instanceof String); + assertInstanceOf(String.class, lastAddedThing.getConfiguration().get("foo")); assertEquals("3", lastAddedThing.getConfiguration().get("foo")); } @@ -164,8 +166,10 @@ public void testApproveWithThingId() { inbox.activate(); inbox.approve(THING_UID, "Test", THING_OTHER_ID); + Thing lastAddedThing = this.lastAddedThing; + assertNotNull(lastAddedThing); assertEquals(THING_OTHER_UID, lastAddedThing.getUID()); - assertTrue(lastAddedThing.getConfiguration().get("foo") instanceof String); + assertInstanceOf(String.class, lastAddedThing.getConfiguration().get("foo")); assertEquals("3", lastAddedThing.getConfiguration().get("foo")); } diff --git a/bundles/org.openhab.core.config.dispatch/pom.xml b/bundles/org.openhab.core.config.dispatch/pom.xml index 7d2dcf65a2f..fe0a6858260 100644 --- a/bundles/org.openhab.core.config.dispatch/pom.xml +++ b/bundles/org.openhab.core.config.dispatch/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.config.dispatch diff --git a/bundles/org.openhab.core.config.dispatch/src/main/java/org/openhab/core/config/dispatch/internal/ConfigDispatcher.java b/bundles/org.openhab.core.config.dispatch/src/main/java/org/openhab/core/config/dispatch/internal/ConfigDispatcher.java index ee1175d6ade..6630db57e81 100644 --- a/bundles/org.openhab.core.config.dispatch/src/main/java/org/openhab/core/config/dispatch/internal/ConfigDispatcher.java +++ b/bundles/org.openhab.core.config.dispatch/src/main/java/org/openhab/core/config/dispatch/internal/ConfigDispatcher.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.dispatch.internal; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; @@ -190,7 +189,7 @@ private Configuration getConfigurationWithContext(String pidWithContext) private void processOrphanExclusivePIDs() { for (String orphanPID : exclusivePIDMap.getOrphanPIDs()) { try { - Configuration configuration = null; + Configuration configuration; if (orphanPID.contains(OpenHAB.SERVICE_CONTEXT_MARKER)) { configuration = getConfigurationWithContext(orphanPID); } else { @@ -229,12 +228,7 @@ public void processConfigFile(File dir) { File[] files = dir.listFiles(); // Sort the files by modification time, // so that the last modified file is processed last. - Arrays.sort(files, new Comparator() { - @Override - public int compare(File left, File right) { - return Long.compare(left.lastModified(), right.lastModified()); - } - }); + Arrays.sort(files, Comparator.comparingLong(File::lastModified)); for (File file : files) { try { internalProcessConfigFile(file); @@ -281,7 +275,7 @@ private String pidFromFilename(File configFile) { } @SuppressWarnings({ "unchecked", "rawtypes" }) - private void internalProcessConfigFile(File configFile) throws IOException, FileNotFoundException { + private void internalProcessConfigFile(File configFile) throws IOException { if (configFile.isDirectory() || !configFile.getName().endsWith(".cfg")) { logger.debug("Ignoring file '{}'", configFile.getName()); return; @@ -440,7 +434,7 @@ private ParseLineResult parseLine(final String filePath, final String line) { .replace(DEFAULT_LIST_STARTING_CHARACTER, "") // .replace(DEFAULT_LIST_ENDING_CHARACTER, "")// .split(DEFAULT_LIST_DELIMITER))// - .map(v -> v.trim())// + .map(String::trim)// .filter(v -> !v.isEmpty())// .toList(); return new ParseLineResult(pid, property.trim(), values); @@ -457,7 +451,7 @@ private ParseLineResult parseLine(final String filePath, final String line) { * Represents a result of parseLine(). */ @NonNullByDefault - private class ParseLineResult { + private static class ParseLineResult { public @Nullable String pid; public @Nullable String property; public @Nullable Object value; @@ -537,7 +531,7 @@ public void initializeProcessPIDMapping() { * @return the list of PIDs which where not processed either during #activate or on file deleted event. */ public List getOrphanPIDs() { - return processedPIDMapping.entrySet().stream().filter(e -> e.getValue() == null).map(e -> e.getKey()) + return processedPIDMapping.entrySet().stream().filter(e -> e.getValue() == null).map(Entry::getKey) .toList(); } @@ -545,8 +539,8 @@ public List getOrphanPIDs() { * Set the exclusivePID list to the processed PIDs (mapped path is not null). */ public void setCurrentExclusivePIDList() { - exclusivePIDs = processedPIDMapping.entrySet().stream().filter(e -> e.getValue() != null) - .map(e -> e.getKey()).toList(); + exclusivePIDs = processedPIDMapping.entrySet().stream().filter(e -> e.getValue() != null).map(Entry::getKey) + .toList(); } public boolean contains(String pid) { diff --git a/bundles/org.openhab.core.config.dispatch/src/main/java/org/openhab/core/config/dispatch/internal/ConfigDispatcherFileWatcher.java b/bundles/org.openhab.core.config.dispatch/src/main/java/org/openhab/core/config/dispatch/internal/ConfigDispatcherFileWatcher.java index 6d64fb49106..909adca75a7 100644 --- a/bundles/org.openhab.core.config.dispatch/src/main/java/org/openhab/core/config/dispatch/internal/ConfigDispatcherFileWatcher.java +++ b/bundles/org.openhab.core.config.dispatch/src/main/java/org/openhab/core/config/dispatch/internal/ConfigDispatcherFileWatcher.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.dispatch/src/test/java/org/openhab/core/config/dispatch/internal/ConfigDispatcherFileWatcherTest.java b/bundles/org.openhab.core.config.dispatch/src/test/java/org/openhab/core/config/dispatch/internal/ConfigDispatcherFileWatcherTest.java index fc4c36f5372..dfc50e8cb73 100644 --- a/bundles/org.openhab.core.config.dispatch/src/test/java/org/openhab/core/config/dispatch/internal/ConfigDispatcherFileWatcherTest.java +++ b/bundles/org.openhab.core.config.dispatch/src/test/java/org/openhab/core/config/dispatch/internal/ConfigDispatcherFileWatcherTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.jupnp/.classpath b/bundles/org.openhab.core.config.jupnp/.classpath new file mode 100644 index 00000000000..58cd399d639 --- /dev/null +++ b/bundles/org.openhab.core.config.jupnp/.classpath @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.openhab.core.config.jupnp/.project b/bundles/org.openhab.core.config.jupnp/.project new file mode 100644 index 00000000000..2ce19369953 --- /dev/null +++ b/bundles/org.openhab.core.config.jupnp/.project @@ -0,0 +1,23 @@ + + + org.openhab.core.config.jupnp + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/bundles/org.openhab.core.config.jupnp/NOTICE b/bundles/org.openhab.core.config.jupnp/NOTICE new file mode 100644 index 00000000000..6c17d0d8a45 --- /dev/null +++ b/bundles/org.openhab.core.config.jupnp/NOTICE @@ -0,0 +1,14 @@ +This content is produced and maintained by the openHAB project. + +* Project home: https://www.openhab.org + +== Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License 2.0 which is available at +https://www.eclipse.org/legal/epl-2.0/. + +== Source Code + +https://github.com/openhab/openhab-core + diff --git a/bundles/org.openhab.core.config.jupnp/pom.xml b/bundles/org.openhab.core.config.jupnp/pom.xml new file mode 100644 index 00000000000..4ad3d61e623 --- /dev/null +++ b/bundles/org.openhab.core.config.jupnp/pom.xml @@ -0,0 +1,25 @@ + + + + 4.0.0 + + + org.openhab.core.bundles + org.openhab.core.reactor.bundles + 4.2.0-SNAPSHOT + + + org.openhab.core.config.jupnp + + openHAB Core :: Bundles :: Configuration jUPnP + + + + org.jupnp + org.jupnp + 3.0.0 + + + + diff --git a/bundles/org.openhab.core.config.jupnp/src/main/java/org/openhab/core/config/jupnp/internal/OHUpnpServiceConfiguration.java b/bundles/org.openhab.core.config.jupnp/src/main/java/org/openhab/core/config/jupnp/internal/OHUpnpServiceConfiguration.java new file mode 100644 index 00000000000..e5707de5adb --- /dev/null +++ b/bundles/org.openhab.core.config.jupnp/src/main/java/org/openhab/core/config/jupnp/internal/OHUpnpServiceConfiguration.java @@ -0,0 +1,52 @@ +/** + * 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.config.jupnp.internal; + +import java.util.concurrent.ExecutorService; + +import org.jupnp.OSGiUpnpServiceConfiguration; +import org.jupnp.QueueingThreadPoolExecutor; +import org.jupnp.UpnpServiceConfiguration; +import org.openhab.basefixes.util.concurrent.LinkedTransferQueue; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.ConfigurationPolicy; + +/** + * Uses the Java 11 {@link LinkedTransferQueue} with jUPnP as workaround for the buggy OpenJDK 17 implementation. + * + * @see JDK-8301341: LinkedTransferQueue does not respect timeout + * for poll() + * @see openhab-core#3755: LinkedTransferQueue in OpenJDK + * 17 sometimes causes high CPU usage + * + * @author Wouter Born - Initial contribution + */ +@Component(configurationPid = "org.jupnp", configurationPolicy = ConfigurationPolicy.REQUIRE, service = UpnpServiceConfiguration.class) +public class OHUpnpServiceConfiguration extends OSGiUpnpServiceConfiguration { + @Override + protected ExecutorService createMainExecutorService() { + return QueueingThreadPoolExecutor.createInstance("upnp-main", threadPoolSize, new LinkedTransferQueue<>()); + } + + @Override + protected ExecutorService createAsyncProtocolExecutorService() { + return QueueingThreadPoolExecutor.createInstance("upnp-async", asyncThreadPoolSize, + new LinkedTransferQueue<>()); + } + + @Override + protected ExecutorService createRemoteProtocolExecutorService() { + return QueueingThreadPoolExecutor.createInstance("upnp-remote", remoteThreadPoolSize, + new LinkedTransferQueue<>()); + } +} diff --git a/bundles/org.openhab.core.config.serial/pom.xml b/bundles/org.openhab.core.config.serial/pom.xml index 7ac734201d9..e800f84315c 100644 --- a/bundles/org.openhab.core.config.serial/pom.xml +++ b/bundles/org.openhab.core.config.serial/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.config.serial diff --git a/bundles/org.openhab.core.config.serial/src/main/java/org/openhab/core/config/serial/internal/SerialConfigOptionProvider.java b/bundles/org.openhab.core.config.serial/src/main/java/org/openhab/core/config/serial/internal/SerialConfigOptionProvider.java index db2f556aa5b..e577671f112 100644 --- a/bundles/org.openhab.core.config.serial/src/main/java/org/openhab/core/config/serial/internal/SerialConfigOptionProvider.java +++ b/bundles/org.openhab.core.config.serial/src/main/java/org/openhab/core/config/serial/internal/SerialConfigOptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.config.serial/src/test/java/org/openhab/core/config/serial/internal/SerialConfigOptionProviderTest.java b/bundles/org.openhab.core.config.serial/src/test/java/org/openhab/core/config/serial/internal/SerialConfigOptionProviderTest.java index 204997a4b07..a587e6bc6a7 100644 --- a/bundles/org.openhab.core.config.serial/src/test/java/org/openhab/core/config/serial/internal/SerialConfigOptionProviderTest.java +++ b/bundles/org.openhab.core.config.serial/src/test/java/org/openhab/core/config/serial/internal/SerialConfigOptionProviderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ephemeris/bnd.bnd b/bundles/org.openhab.core.ephemeris/bnd.bnd new file mode 100644 index 00000000000..0cee4faf495 --- /dev/null +++ b/bundles/org.openhab.core.ephemeris/bnd.bnd @@ -0,0 +1,5 @@ +Automatic-Module-Name: ${def;bsn} +Bundle-SymbolicName: ${project.artifactId} +Import-Package: \ + *, \ + de.focus_shift.jollyday.jackson diff --git a/bundles/org.openhab.core.ephemeris/pom.xml b/bundles/org.openhab.core.ephemeris/pom.xml index 820aa10dfbf..73c992077e8 100644 --- a/bundles/org.openhab.core.ephemeris/pom.xml +++ b/bundles/org.openhab.core.ephemeris/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.ephemeris diff --git a/bundles/org.openhab.core.ephemeris/src/main/java/org/openhab/core/ephemeris/EphemerisManager.java b/bundles/org.openhab.core.ephemeris/src/main/java/org/openhab/core/ephemeris/EphemerisManager.java index 1b7c92880d2..05f8870e713 100644 --- a/bundles/org.openhab.core.ephemeris/src/main/java/org/openhab/core/ephemeris/EphemerisManager.java +++ b/bundles/org.openhab.core.ephemeris/src/main/java/org/openhab/core/ephemeris/EphemerisManager.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ephemeris/src/main/java/org/openhab/core/ephemeris/internal/EphemerisManagerImpl.java b/bundles/org.openhab.core.ephemeris/src/main/java/org/openhab/core/ephemeris/internal/EphemerisManagerImpl.java index a1a35fa2073..6b744dd6917 100644 --- a/bundles/org.openhab.core.ephemeris/src/main/java/org/openhab/core/ephemeris/internal/EphemerisManagerImpl.java +++ b/bundles/org.openhab.core.ephemeris/src/main/java/org/openhab/core/ephemeris/internal/EphemerisManagerImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -54,12 +54,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import de.jollyday.Holiday; -import de.jollyday.HolidayManager; -import de.jollyday.ManagerParameter; -import de.jollyday.ManagerParameters; -import de.jollyday.parameter.CalendarPartManagerParameter; -import de.jollyday.util.ResourceUtil; +import de.focus_shift.jollyday.core.Holiday; +import de.focus_shift.jollyday.core.HolidayManager; +import de.focus_shift.jollyday.core.ManagerParameter; +import de.focus_shift.jollyday.core.ManagerParameters; +import de.focus_shift.jollyday.core.parameter.CalendarPartManagerParameter; +import de.focus_shift.jollyday.core.util.ResourceUtil; /** * This service provides functionality around ephemeris services and is the central service to be used directly by diff --git a/bundles/org.openhab.core.ephemeris/src/main/resources/jollyday/holidays/Holidays_dk.xml b/bundles/org.openhab.core.ephemeris/src/main/resources/jollyday/holidays/Holidays_dk.xml deleted file mode 100644 index e7510def3c3..00000000000 --- a/bundles/org.openhab.core.ephemeris/src/main/resources/jollyday/holidays/Holidays_dk.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/bundles/org.openhab.core.id/pom.xml b/bundles/org.openhab.core.id/pom.xml index 162d5223f68..71ed95058d5 100644 --- a/bundles/org.openhab.core.id/pom.xml +++ b/bundles/org.openhab.core.id/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.id diff --git a/bundles/org.openhab.core.id/src/main/java/org/openhab/core/id/InstanceUUID.java b/bundles/org.openhab.core.id/src/main/java/org/openhab/core/id/InstanceUUID.java index 7162133ab2a..2f66ec6158f 100644 --- a/bundles/org.openhab.core.id/src/main/java/org/openhab/core/id/InstanceUUID.java +++ b/bundles/org.openhab.core.id/src/main/java/org/openhab/core/id/InstanceUUID.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.id/src/main/java/org/openhab/core/id/internal/UUIDResource.java b/bundles/org.openhab.core.id/src/main/java/org/openhab/core/id/internal/UUIDResource.java index eff223f4562..78e0dfc81ca 100644 --- a/bundles/org.openhab.core.id/src/main/java/org/openhab/core/id/internal/UUIDResource.java +++ b/bundles/org.openhab.core.id/src/main/java/org/openhab/core/id/internal/UUIDResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.id/src/test/java/org/openhab/core/id/InstanceUUIDTest.java b/bundles/org.openhab.core.id/src/test/java/org/openhab/core/id/InstanceUUIDTest.java index 3be823f8e93..10c212e7ec6 100644 --- a/bundles/org.openhab.core.id/src/test/java/org/openhab/core/id/InstanceUUIDTest.java +++ b/bundles/org.openhab.core.id/src/test/java/org/openhab/core/id/InstanceUUIDTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.bin2json/pom.xml b/bundles/org.openhab.core.io.bin2json/pom.xml index d83ca2482bd..e9aa5bed2af 100644 --- a/bundles/org.openhab.core.io.bin2json/pom.xml +++ b/bundles/org.openhab.core.io.bin2json/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.bin2json diff --git a/bundles/org.openhab.core.io.bin2json/src/main/java/org/openhab/core/io/bin2json/Bin2Json.java b/bundles/org.openhab.core.io.bin2json/src/main/java/org/openhab/core/io/bin2json/Bin2Json.java index f268a9b4316..3b592614d9f 100644 --- a/bundles/org.openhab.core.io.bin2json/src/main/java/org/openhab/core/io/bin2json/Bin2Json.java +++ b/bundles/org.openhab.core.io.bin2json/src/main/java/org/openhab/core/io/bin2json/Bin2Json.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 Bin2Json(String parserRule) throws ConversionException { try { parser = JBBPParser.prepare(parserRule); } catch (JBBPException e) { - throw new ConversionException(String.format("Illegal parser rule, reason: %s", e.getMessage(), e)); + throw new ConversionException(String.format("Illegal parser rule, reason: %s", e.getMessage()), e); } } @@ -103,7 +103,7 @@ public JsonObject convert(String hexString) throws ConversionException { try { return convert(HexUtils.hexToBytes(hexString)); } catch (IllegalArgumentException e) { - throw new ConversionException(String.format("Illegal hexstring , reason: %s", e.getMessage(), e)); + throw new ConversionException(String.format("Illegal hexstring , reason: %s", e.getMessage()), e); } } @@ -117,10 +117,8 @@ public JsonObject convert(String hexString) throws ConversionException { public JsonObject convert(byte[] data) throws ConversionException { try { return convert(parser.parse(data)); - } catch (IOException e) { - throw new ConversionException(String.format("Unexpected error, reason: %s", e.getMessage(), e)); - } catch (JBBPException e) { - throw new ConversionException(String.format("Unexpected error, reason: %s", e.getMessage(), e)); + } catch (IOException | JBBPException e) { + throw new ConversionException(String.format("Unexpected error, reason: %s", e.getMessage()), e); } } @@ -134,10 +132,8 @@ public JsonObject convert(byte[] data) throws ConversionException { public JsonObject convert(InputStream inputStream) throws ConversionException { try { return convert(parser.parse(inputStream)); - } catch (IOException e) { - throw new ConversionException(String.format("Unexpected error, reason: %s", e.getMessage(), e)); - } catch (JBBPException e) { - throw new ConversionException(String.format("Unexpected error, reason: %s", e.getMessage(), e)); + } catch (IOException | JBBPException e) { + throw new ConversionException(String.format("Unexpected error, reason: %s", e.getMessage()), e); } } @@ -151,7 +147,7 @@ private JsonObject convert(JBBPFieldStruct data) throws ConversionException { } return json; } catch (JBBPException e) { - throw new ConversionException(String.format("Unexpected error, reason: %s", e.getMessage(), e)); + throw new ConversionException(String.format("Unexpected error, reason: %s", e.getMessage()), e); } } diff --git a/bundles/org.openhab.core.io.bin2json/src/main/java/org/openhab/core/io/bin2json/ConversionException.java b/bundles/org.openhab.core.io.bin2json/src/main/java/org/openhab/core/io/bin2json/ConversionException.java index bd689ee163f..951dba511cf 100644 --- a/bundles/org.openhab.core.io.bin2json/src/main/java/org/openhab/core/io/bin2json/ConversionException.java +++ b/bundles/org.openhab.core.io.bin2json/src/main/java/org/openhab/core/io/bin2json/ConversionException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.bin2json/src/test/java/org/openhab/core/io/bin2json/Bin2JsonTest.java b/bundles/org.openhab.core.io.bin2json/src/test/java/org/openhab/core/io/bin2json/Bin2JsonTest.java index 09f0beba636..6d946f5eba6 100644 --- a/bundles/org.openhab.core.io.bin2json/src/test/java/org/openhab/core/io/bin2json/Bin2JsonTest.java +++ b/bundles/org.openhab.core.io.bin2json/src/test/java/org/openhab/core/io/bin2json/Bin2JsonTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console.eclipse/pom.xml b/bundles/org.openhab.core.io.console.eclipse/pom.xml index de8da32578f..b20abd2d1f3 100644 --- a/bundles/org.openhab.core.io.console.eclipse/pom.xml +++ b/bundles/org.openhab.core.io.console.eclipse/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.console.eclipse diff --git a/bundles/org.openhab.core.io.console.eclipse/src/main/java/org/openhab/core/io/console/eclipse/internal/ConsoleSupportEclipse.java b/bundles/org.openhab.core.io.console.eclipse/src/main/java/org/openhab/core/io/console/eclipse/internal/ConsoleSupportEclipse.java index 45884f49ba2..fc526b97f55 100644 --- a/bundles/org.openhab.core.io.console.eclipse/src/main/java/org/openhab/core/io/console/eclipse/internal/ConsoleSupportEclipse.java +++ b/bundles/org.openhab.core.io.console.eclipse/src/main/java/org/openhab/core/io/console/eclipse/internal/ConsoleSupportEclipse.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.util.Collections; import java.util.HashSet; import java.util.List; -import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; @@ -64,9 +63,7 @@ private ConsoleCommandExtension getConsoleCommandExtension(final String cmd) { } private Collection getConsoleCommandExtensions() { - final Set set = new HashSet<>(); - set.addAll(consoleCommandExtensions.values()); - return set; + return new HashSet<>(consoleCommandExtensions.values()); } /** diff --git a/bundles/org.openhab.core.io.console.eclipse/src/main/java/org/openhab/core/io/console/eclipse/internal/OSGiConsole.java b/bundles/org.openhab.core.io.console.eclipse/src/main/java/org/openhab/core/io/console/eclipse/internal/OSGiConsole.java index 9a2e029de9f..79aeebc6ad6 100644 --- a/bundles/org.openhab.core.io.console.eclipse/src/main/java/org/openhab/core/io/console/eclipse/internal/OSGiConsole.java +++ b/bundles/org.openhab.core.io.console.eclipse/src/main/java/org/openhab/core/io/console/eclipse/internal/OSGiConsole.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console.karaf/pom.xml b/bundles/org.openhab.core.io.console.karaf/pom.xml index 82a53b412bf..7815528ad6f 100644 --- a/bundles/org.openhab.core.io.console.karaf/pom.xml +++ b/bundles/org.openhab.core.io.console.karaf/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.console.karaf diff --git a/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/CommandWrapper.java b/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/CommandWrapper.java index 243d82f70d9..2a2e7c40478 100644 --- a/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/CommandWrapper.java +++ b/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/CommandWrapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,8 +52,8 @@ public class CommandWrapper implements Command, Action { /** * The constructor for the "help" instance of this class. This instance will be created by - * org.apache.karaf.shell.impl.action.command.ManagerImpl.instantiate(Class, Registry) and - * is used to print all usages from the `openhab` scope. + * {@code org.apache.karaf.shell.impl.action.command.ManagerImpl.instantiate(Class, Registry)} and + * is used to print all usages from the {@code openhab} scope. * The wrapped command is unused here because the karaf infrastructure will call the {@link #execute()} method. */ public CommandWrapper() { diff --git a/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/CompleterWrapper.java b/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/CompleterWrapper.java index a20671bd36c..0079f8b4ed6 100644 --- a/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/CompleterWrapper.java +++ b/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/CompleterWrapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/ConsoleSupportKaraf.java b/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/ConsoleSupportKaraf.java index a316b3ca90d..91bb8424dfe 100644 --- a/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/ConsoleSupportKaraf.java +++ b/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/ConsoleSupportKaraf.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/InstallServiceCommand.java b/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/InstallServiceCommand.java index ab157e2e81c..02565415c86 100644 --- a/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/InstallServiceCommand.java +++ b/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/InstallServiceCommand.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -415,7 +415,7 @@ private void safeClose(InputStream is) { /** * Silently close outputstream * - * @param is + * @param os * outputstream */ private void safeClose(OutputStream os) { diff --git a/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/OSGiConsole.java b/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/OSGiConsole.java index 1941058327b..c55d6b44988 100644 --- a/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/OSGiConsole.java +++ b/bundles/org.openhab.core.io.console.karaf/src/main/java/org/openhab/core/io/console/karaf/internal/OSGiConsole.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console.karaf/src/test/java/org/openhab/core/io/console/karaf/internal/CompleterWrapperTest.java b/bundles/org.openhab.core.io.console.karaf/src/test/java/org/openhab/core/io/console/karaf/internal/CompleterWrapperTest.java index ec5bfeb4911..2877bcc0e0c 100644 --- a/bundles/org.openhab.core.io.console.karaf/src/test/java/org/openhab/core/io/console/karaf/internal/CompleterWrapperTest.java +++ b/bundles/org.openhab.core.io.console.karaf/src/test/java/org/openhab/core/io/console/karaf/internal/CompleterWrapperTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console.rfc147/pom.xml b/bundles/org.openhab.core.io.console.rfc147/pom.xml index 83103b501eb..40a82490646 100644 --- a/bundles/org.openhab.core.io.console.rfc147/pom.xml +++ b/bundles/org.openhab.core.io.console.rfc147/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.console.rfc147 diff --git a/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/CommandWrapper.java b/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/CommandWrapper.java index dde7cc6fe6d..5c64236ebc5 100644 --- a/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/CommandWrapper.java +++ b/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/CommandWrapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/ConsoleCommandsContainer.java b/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/ConsoleCommandsContainer.java index c988051b774..32251ff2952 100644 --- a/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/ConsoleCommandsContainer.java +++ b/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/ConsoleCommandsContainer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/ConsoleSupportRfc147.java b/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/ConsoleSupportRfc147.java index 8b38595337b..a7c08e2b4a8 100644 --- a/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/ConsoleSupportRfc147.java +++ b/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/ConsoleSupportRfc147.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/OSGiConsole.java b/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/OSGiConsole.java index 5f3ea8a85d4..6e0c6a0735c 100644 --- a/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/OSGiConsole.java +++ b/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/OSGiConsole.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/extension/HelpConsoleCommandExtension.java b/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/extension/HelpConsoleCommandExtension.java index b634d5be0c7..0c00f8340c3 100644 --- a/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/extension/HelpConsoleCommandExtension.java +++ b/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/openhab/core/io/console/rfc147/internal/extension/HelpConsoleCommandExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console/pom.xml b/bundles/org.openhab.core.io.console/pom.xml index a35e5d748ab..bb92813b12d 100644 --- a/bundles/org.openhab.core.io.console/pom.xml +++ b/bundles/org.openhab.core.io.console/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.console @@ -20,6 +20,11 @@ org.openhab.core ${project.version} + + org.openhab.core.bundles + org.openhab.core.addon + ${project.version} + diff --git a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/Console.java b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/Console.java index 5dc1005ca03..a3b6dbab18a 100644 --- a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/Console.java +++ b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/Console.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console/src/main/java/org/openhab/core/io/console/ConsoleCommandCompleter.java b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/ConsoleCommandCompleter.java index 49518392908..f17cf003b34 100644 --- a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/ConsoleCommandCompleter.java +++ b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/ConsoleCommandCompleter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console/src/main/java/org/openhab/core/io/console/ConsoleInterpreter.java b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/ConsoleInterpreter.java index 01c8d076eb4..60536d13626 100644 --- a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/ConsoleInterpreter.java +++ b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/ConsoleInterpreter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console/src/main/java/org/openhab/core/io/console/StringsCompleter.java b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/StringsCompleter.java index 43801b9233b..64fa99a858e 100644 --- a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/StringsCompleter.java +++ b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/StringsCompleter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console/src/main/java/org/openhab/core/io/console/extensions/AbstractConsoleCommandExtension.java b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/extensions/AbstractConsoleCommandExtension.java index 099e0320fad..ab273d23bf0 100644 --- a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/extensions/AbstractConsoleCommandExtension.java +++ b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/extensions/AbstractConsoleCommandExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +32,7 @@ public abstract class AbstractConsoleCommandExtension implements ConsoleCommandE * @param cmd The command the extension is used for. * @param desc The description what this extension is handling. */ - public AbstractConsoleCommandExtension(final String cmd, final String desc) { + protected AbstractConsoleCommandExtension(final String cmd, final String desc) { this.cmd = cmd; this.desc = desc; } diff --git a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/extensions/ConsoleCommandExtension.java b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/extensions/ConsoleCommandExtension.java index 782f0ca3ad7..1b08b62f81b 100644 --- a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/extensions/ConsoleCommandExtension.java +++ b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/extensions/ConsoleCommandExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console/src/main/java/org/openhab/core/io/console/internal/extension/AddonConsoleCommandExtension.java b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/AddonConsoleCommandExtension.java new file mode 100644 index 00000000000..8e04601c2b8 --- /dev/null +++ b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/AddonConsoleCommandExtension.java @@ -0,0 +1,185 @@ +/** + * 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.io.console.internal.extension; + +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.core.addon.Addon; +import org.openhab.core.addon.AddonService; +import org.openhab.core.io.console.Console; +import org.openhab.core.io.console.ConsoleCommandCompleter; +import org.openhab.core.io.console.StringsCompleter; +import org.openhab.core.io.console.extensions.AbstractConsoleCommandExtension; +import org.openhab.core.io.console.extensions.ConsoleCommandExtension; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.component.annotations.ReferenceCardinality; + +/** + * Console command extension to manage add-ons + * + * @author Jan N. Klug - Initial contribution + */ +@Component(service = ConsoleCommandExtension.class) +@NonNullByDefault +public class AddonConsoleCommandExtension extends AbstractConsoleCommandExtension { + + private static final String SUBCMD_LIST = "list"; + private static final String SUBCMD_SERVICES = "services"; + private static final String SUBCMD_INSTALL = "install"; + private static final String SUBCMD_UNINSTALL = "uninstall"; + private static final StringsCompleter SUBCMD_COMPLETER = new StringsCompleter( + List.of(SUBCMD_LIST, SUBCMD_SERVICES, SUBCMD_INSTALL, SUBCMD_UNINSTALL), false); + + private class AddonConsoleCommandCompleter implements ConsoleCommandCompleter { + @Override + public boolean complete(String[] args, int cursorArgumentIndex, int cursorPosition, List candidates) { + if (cursorArgumentIndex <= 0) { + return SUBCMD_COMPLETER.complete(args, cursorArgumentIndex, cursorPosition, candidates); + } + return false; + } + } + + private final Map addonServices = new ConcurrentHashMap<>(); + + @Activate + public AddonConsoleCommandExtension() { + super("addons", "Manage add-ons."); + } + + @Reference(cardinality = ReferenceCardinality.MULTIPLE) + public void bindAddonService(AddonService addonService) { + addonServices.put(addonService.getId(), addonService); + } + + public void unbindAddonService(AddonService addonService) { + addonServices.remove(addonService.getId()); + } + + @Override + public List getUsages() { + return List.of(buildCommandUsage(SUBCMD_SERVICES, "list all available add-on services"), + buildCommandUsage(SUBCMD_LIST + " []", + "lists names of all add-ons (from the named service, if given)"), + buildCommandUsage(SUBCMD_INSTALL + " ", "installs the given add-on"), + buildCommandUsage(SUBCMD_UNINSTALL + " ", "uninstalls the given add-on")); + } + + @Override + public void execute(String[] args, Console console) { + if (args.length > 0) { + String subCommand = args[0]; + switch (subCommand) { + case SUBCMD_SERVICES: + listServices(console); + break; + case SUBCMD_LIST: + listAddons(console, (args.length < 2) ? "" : args[1]); + break; + case SUBCMD_INSTALL: + if (args.length == 2) { + installAddon(console, args[1]); + } else { + console.println("Specify the UID of the add-on to install: " + getCommand() + " " + + SUBCMD_INSTALL + " "); + } + break; + case SUBCMD_UNINSTALL: + if (args.length == 2) { + uninstallAddon(console, args[1]); + } else { + console.println("Specify the UID of the add-on to uninstall: " + getCommand() + " " + + SUBCMD_UNINSTALL + " "); + } + break; + default: + console.println("Unknown command '" + subCommand + "'"); + printUsage(console); + break; + } + } else { + printUsage(console); + } + } + + @Override + public @Nullable ConsoleCommandCompleter getCompleter() { + return new AddonConsoleCommandCompleter(); + } + + private void listServices(Console console) { + addonServices.values().forEach(s -> console.println(String.format("%-20s %s", s.getId(), s.getName()))); + } + + private void listAddons(Console console, String serviceId) { + List addons; + if (serviceId.isBlank()) { + addons = addonServices.values().stream().map(s -> s.getAddons(null)).flatMap(List::stream).toList(); + } else { + AddonService service = addonServices.get(serviceId); + if (service == null) { + console.println("Add-on service '" + serviceId + "' is not known."); + return; + } + addons = service.getAddons(null); + } + addons.forEach(addon -> console.println(String.format("%s %-45s %-20s %s", addon.isInstalled() ? "i" : " ", + addon.getUid(), addon.getVersion().isBlank() ? "not set" : addon.getVersion(), addon.getLabel()))); + } + + private void installAddon(Console console, String addonUid) { + String[] parts = addonUid.split(":"); + String serviceId = parts.length == 2 ? parts[0] : "karaf"; + String addonId = parts.length == 2 ? parts[1] : parts[0]; + AddonService service = addonServices.get(serviceId); + if (service == null) { + console.println("Could not find requested add-on service. Add-on " + addonUid + " not installed."); + } else { + Addon addon = service.getAddon(addonId, null); + if (addon == null) { + console.println("Could not find add-on in add-on service. Add-on " + addonUid + " not installed."); + } else if (addon.isInstalled()) { + console.println("Add-on " + addonUid + " is already installed."); + } else { + service.install(addonId); + console.println("Installed " + addonUid + "."); + } + } + } + + private void uninstallAddon(Console console, String addonUid) { + String[] parts = addonUid.split(":"); + String serviceId = parts.length == 2 ? parts[0] : "karaf"; + String addonId = parts.length == 2 ? parts[1] : parts[0]; + AddonService service = addonServices.get(serviceId); + if (service == null) { + console.println("Could not find requested add-on service. Add-on " + addonUid + " not uninstalled."); + } else { + Addon addon = service.getAddon(addonId, null); + if (addon == null) { + console.println("Could not find add-on in add-on service. Add-on " + addonUid + " not uninstalled."); + } else if (!addon.isInstalled()) { + console.println("Add-on " + addonUid + " is not installed."); + } else { + service.uninstall(addonId); + console.println("Uninstalled " + addonUid + "."); + } + } + } +} diff --git a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandCompleter.java b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandCompleter.java index a3981197b2f..1422611969b 100644 --- a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandCompleter.java +++ b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandCompleter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,8 +50,8 @@ public ItemConsoleCommandCompleter(ItemRegistry itemRegistry, Function candidates) { if (cursorArgumentIndex <= 0) { - return new StringsCompleter(itemRegistry.getAll().stream().map(i -> i.getName()).toList(), true) - .complete(args, cursorArgumentIndex, cursorPosition, candidates); + return new StringsCompleter(itemRegistry.getAll().stream().map(Item::getName).toList(), true).complete(args, + cursorArgumentIndex, cursorPosition, candidates); } var localDataTypeGetter = dataTypeGetter; if (cursorArgumentIndex == 1 && localDataTypeGetter != null) { diff --git a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandExtension.java b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandExtension.java index de1cc2100c2..57a3dc9b073 100644 --- a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandExtension.java +++ b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -72,7 +72,7 @@ public boolean complete(String[] args, int cursorArgumentIndex, int cursorPositi default: return false; } - return new StringsCompleter(items.stream().map(i -> i.getName()).toList(), true).complete(args, + return new StringsCompleter(items.stream().map(Item::getName).toList(), true).complete(args, cursorArgumentIndex, cursorPosition, candidates); } if (cursorArgumentIndex == 2 && args[0].equals(SUBCMD_RMTAG)) { diff --git a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/MetadataConsoleCommandExtension.java b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/MetadataConsoleCommandExtension.java index 05c2778960c..17faa9d2afe 100644 --- a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/MetadataConsoleCommandExtension.java +++ b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/MetadataConsoleCommandExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console/src/main/java/org/openhab/core/io/console/internal/extension/SendConsoleCommandExtension.java b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/SendConsoleCommandExtension.java index c68a89e9794..f5243128684 100644 --- a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/SendConsoleCommandExtension.java +++ b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/SendConsoleCommandExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console/src/main/java/org/openhab/core/io/console/internal/extension/StatusConsoleCommandExtension.java b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/StatusConsoleCommandExtension.java index 6e35fc66bda..428933f97e4 100644 --- a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/StatusConsoleCommandExtension.java +++ b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/StatusConsoleCommandExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console/src/main/java/org/openhab/core/io/console/internal/extension/UpdateConsoleCommandExtension.java b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/UpdateConsoleCommandExtension.java index e1cefcb5008..0b1af1a93ad 100644 --- a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/UpdateConsoleCommandExtension.java +++ b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/UpdateConsoleCommandExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console/src/main/java/org/openhab/core/io/console/internal/extension/UserConsoleCommandExtension.java b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/UserConsoleCommandExtension.java index ed204399ae4..433fd79ae09 100644 --- a/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/UserConsoleCommandExtension.java +++ b/bundles/org.openhab.core.io.console/src/main/java/org/openhab/core/io/console/internal/extension/UserConsoleCommandExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console/src/test/java/org/openhab/core/io/console/StringsCompleterTest.java b/bundles/org.openhab.core.io.console/src/test/java/org/openhab/core/io/console/StringsCompleterTest.java index 598b34afce8..83f57555095 100644 --- a/bundles/org.openhab.core.io.console/src/test/java/org/openhab/core/io/console/StringsCompleterTest.java +++ b/bundles/org.openhab.core.io.console/src/test/java/org/openhab/core/io/console/StringsCompleterTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console/src/test/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandCompleterTest.java b/bundles/org.openhab.core.io.console/src/test/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandCompleterTest.java index ecae45ba5ff..9422dbfb7c8 100644 --- a/bundles/org.openhab.core.io.console/src/test/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandCompleterTest.java +++ b/bundles/org.openhab.core.io.console/src/test/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandCompleterTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.console/src/test/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandExtensionTest.java b/bundles/org.openhab.core.io.console/src/test/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandExtensionTest.java index c71e03c29b1..f8dcfa1e510 100644 --- a/bundles/org.openhab.core.io.console/src/test/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandExtensionTest.java +++ b/bundles/org.openhab.core.io.console/src/test/java/org/openhab/core/io/console/internal/extension/ItemConsoleCommandExtensionTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.http.auth/pom.xml b/bundles/org.openhab.core.io.http.auth/pom.xml index 2872f4b54f0..70a3681c645 100644 --- a/bundles/org.openhab.core.io.http.auth/pom.xml +++ b/bundles/org.openhab.core.io.http.auth/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.http.auth diff --git a/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/CredentialsExtractor.java b/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/CredentialsExtractor.java index 813103a4200..dd7154d2477 100644 --- a/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/CredentialsExtractor.java +++ b/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/CredentialsExtractor.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/AbstractAuthPageServlet.java b/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/AbstractAuthPageServlet.java index ff3e18aa610..db4f8e28b1e 100644 --- a/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/AbstractAuthPageServlet.java +++ b/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/AbstractAuthPageServlet.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 @@ public abstract class AbstractAuthPageServlet extends HttpServlet { protected String pageTemplate; - public AbstractAuthPageServlet(BundleContext bundleContext, @Reference UserRegistry userRegistry, + protected AbstractAuthPageServlet(BundleContext bundleContext, @Reference UserRegistry userRegistry, @Reference AuthenticationProvider authProvider, @Reference LocaleProvider localeProvider) { this.userRegistry = userRegistry; this.authProvider = authProvider; diff --git a/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/AuthenticationHandler.java b/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/AuthenticationHandler.java index 0fd2fd60b60..6d15c00a80d 100644 --- a/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/AuthenticationHandler.java +++ b/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/AuthenticationHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/AuthorizePageServlet.java b/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/AuthorizePageServlet.java index b116d3051e5..2aed01a694a 100644 --- a/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/AuthorizePageServlet.java +++ b/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/AuthorizePageServlet.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -77,7 +77,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se Map params = req.getParameterMap(); try { - String message = ""; + String message; String scope = params.containsKey("scope") ? params.get("scope")[0] : ""; String clientId = params.containsKey("client_id") ? params.get("client_id")[0] : ""; diff --git a/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/ChangePasswordPageServlet.java b/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/ChangePasswordPageServlet.java index 6a2f522b23a..dc460e73be9 100644 --- a/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/ChangePasswordPageServlet.java +++ b/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/ChangePasswordPageServlet.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/CreateAPITokenPageServlet.java b/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/CreateAPITokenPageServlet.java index f3c21a728aa..f99974845cd 100644 --- a/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/CreateAPITokenPageServlet.java +++ b/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/CreateAPITokenPageServlet.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/RedirectHandler.java b/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/RedirectHandler.java index daff206cd96..7b0dd0fc404 100644 --- a/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/RedirectHandler.java +++ b/bundles/org.openhab.core.io.http.auth/src/main/java/org/openhab/core/io/http/auth/internal/RedirectHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.http/pom.xml b/bundles/org.openhab.core.io.http/pom.xml index fad7fddf0f4..8c81c5de554 100644 --- a/bundles/org.openhab.core.io.http/pom.xml +++ b/bundles/org.openhab.core.io.http/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.http diff --git a/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/Handler.java b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/Handler.java index a9d38b566e0..6330e414614 100644 --- a/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/Handler.java +++ b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/Handler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.http/src/main/java/org/openhab/core/io/http/HandlerContext.java b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/HandlerContext.java index 8d9949ad9e0..0b80f88bb93 100644 --- a/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/HandlerContext.java +++ b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/HandlerContext.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.http/src/main/java/org/openhab/core/io/http/HandlerPriorities.java b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/HandlerPriorities.java index b9c8dc7c105..1eac78eba8a 100644 --- a/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/HandlerPriorities.java +++ b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/HandlerPriorities.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.http/src/main/java/org/openhab/core/io/http/HttpContextFactoryService.java b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/HttpContextFactoryService.java index 5704a93b47a..c174538f53d 100644 --- a/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/HttpContextFactoryService.java +++ b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/HttpContextFactoryService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.http/src/main/java/org/openhab/core/io/http/WrappingHttpContext.java b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/WrappingHttpContext.java index ca6ce4dd10d..db22f0a8973 100644 --- a/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/WrappingHttpContext.java +++ b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/WrappingHttpContext.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.http/src/main/java/org/openhab/core/io/http/internal/BundleHttpContext.java b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/BundleHttpContext.java index 78e1734ca91..ed5a7645e14 100644 --- a/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/BundleHttpContext.java +++ b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/BundleHttpContext.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.http/src/main/java/org/openhab/core/io/http/internal/CatchHandler.java b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/CatchHandler.java index 128af80318e..0d597712165 100644 --- a/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/CatchHandler.java +++ b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/CatchHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.http/src/main/java/org/openhab/core/io/http/internal/DefaultHandlerContext.java b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/DefaultHandlerContext.java index 295d9c1faf1..6491edec960 100644 --- a/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/DefaultHandlerContext.java +++ b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/DefaultHandlerContext.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.http/src/main/java/org/openhab/core/io/http/internal/DelegatingHttpContext.java b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/DelegatingHttpContext.java index 2fd58a0c948..08f54170a54 100644 --- a/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/DelegatingHttpContext.java +++ b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/DelegatingHttpContext.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.http/src/main/java/org/openhab/core/io/http/internal/HttpContextFactoryServiceImpl.java b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/HttpContextFactoryServiceImpl.java index 97d5997805b..665472d440f 100644 --- a/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/HttpContextFactoryServiceImpl.java +++ b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/HttpContextFactoryServiceImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.http/src/main/java/org/openhab/core/io/http/internal/OpenHABHttpContext.java b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/OpenHABHttpContext.java index c37a8e782c4..d1893e11c68 100644 --- a/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/OpenHABHttpContext.java +++ b/bundles/org.openhab.core.io.http/src/main/java/org/openhab/core/io/http/internal/OpenHABHttpContext.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.http/src/test/java/org/openhab/core/io/http/internal/HttpContextFactoryServiceImplTest.java b/bundles/org.openhab.core.io.http/src/test/java/org/openhab/core/io/http/internal/HttpContextFactoryServiceImplTest.java index 368a7703706..612d462498b 100644 --- a/bundles/org.openhab.core.io.http/src/test/java/org/openhab/core/io/http/internal/HttpContextFactoryServiceImplTest.java +++ b/bundles/org.openhab.core.io.http/src/test/java/org/openhab/core/io/http/internal/HttpContextFactoryServiceImplTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.jetty.certificate/pom.xml b/bundles/org.openhab.core.io.jetty.certificate/pom.xml index 2034757bd44..33cf7fd5993 100644 --- a/bundles/org.openhab.core.io.jetty.certificate/pom.xml +++ b/bundles/org.openhab.core.io.jetty.certificate/pom.xml @@ -6,7 +6,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.jetty.certificate diff --git a/bundles/org.openhab.core.io.jetty.certificate/src/main/java/org/openhab/core/io/jetty/certificate/internal/CertificateGenerator.java b/bundles/org.openhab.core.io.jetty.certificate/src/main/java/org/openhab/core/io/jetty/certificate/internal/CertificateGenerator.java index 7ed9834565e..bfda450d9a9 100644 --- a/bundles/org.openhab.core.io.jetty.certificate/src/main/java/org/openhab/core/io/jetty/certificate/internal/CertificateGenerator.java +++ b/bundles/org.openhab.core.io.jetty.certificate/src/main/java/org/openhab/core/io/jetty/certificate/internal/CertificateGenerator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.monitor/pom.xml b/bundles/org.openhab.core.io.monitor/pom.xml index c9cca62175f..7ec8868abd3 100644 --- a/bundles/org.openhab.core.io.monitor/pom.xml +++ b/bundles/org.openhab.core.io.monitor/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.monitor diff --git a/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/MeterRegistryProvider.java b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/MeterRegistryProvider.java index 63c5805e149..1872d9ac77b 100644 --- a/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/MeterRegistryProvider.java +++ b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/MeterRegistryProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/DefaultMetricsRegistration.java b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/DefaultMetricsRegistration.java index e31fae35421..cc122a5eec7 100644 --- a/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/DefaultMetricsRegistration.java +++ b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/DefaultMetricsRegistration.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/EventLogger.java b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/EventLogger.java index 2f857b7ebc2..e8dd54b01b6 100644 --- a/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/EventLogger.java +++ b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/EventLogger.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/BundleStateMetric.java b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/BundleStateMetric.java index 2d6e9aed6fc..b7225e46b27 100644 --- a/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/BundleStateMetric.java +++ b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/BundleStateMetric.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/EventCountMetric.java b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/EventCountMetric.java index c518d39ecb4..4513f682901 100644 --- a/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/EventCountMetric.java +++ b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/EventCountMetric.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/JVMMetric.java b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/JVMMetric.java index f3b029d4189..807f46c8c7c 100644 --- a/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/JVMMetric.java +++ b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/JVMMetric.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/OpenhabCoreMeterBinder.java b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/OpenhabCoreMeterBinder.java index 6f3598da04e..ddb8a4f5303 100644 --- a/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/OpenhabCoreMeterBinder.java +++ b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/OpenhabCoreMeterBinder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/RuleMetric.java b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/RuleMetric.java index f5c00cc7fe1..e77e5313f68 100644 --- a/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/RuleMetric.java +++ b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/RuleMetric.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/ThingStateMetric.java b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/ThingStateMetric.java index 4501bbacfed..471ecb12ff3 100644 --- a/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/ThingStateMetric.java +++ b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/ThingStateMetric.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/ThreadPoolMetric.java b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/ThreadPoolMetric.java index d42184417e7..46f6314dcfd 100644 --- a/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/ThreadPoolMetric.java +++ b/bundles/org.openhab.core.io.monitor/src/main/java/org/openhab/core/io/monitor/internal/metrics/ThreadPoolMetric.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.monitor/src/test/java/org/openhab/core/io/monitor/internal/metrics/ThingStateMetricTest.java b/bundles/org.openhab.core.io.monitor/src/test/java/org/openhab/core/io/monitor/internal/metrics/ThingStateMetricTest.java index b6448a5a5e2..92fcd791d4c 100644 --- a/bundles/org.openhab.core.io.monitor/src/test/java/org/openhab/core/io/monitor/internal/metrics/ThingStateMetricTest.java +++ b/bundles/org.openhab.core.io.monitor/src/test/java/org/openhab/core/io/monitor/internal/metrics/ThingStateMetricTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/pom.xml b/bundles/org.openhab.core.io.net/pom.xml index 23c9df05d82..f17dea444a4 100644 --- a/bundles/org.openhab.core.io.net/pom.xml +++ b/bundles/org.openhab.core.io.net/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.net diff --git a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/exec/ExecUtil.java b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/exec/ExecUtil.java index 467d288115a..d911c10296b 100644 --- a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/exec/ExecUtil.java +++ b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/exec/ExecUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/main/java/org/openhab/core/io/net/http/ExtensibleTrustManager.java b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/ExtensibleTrustManager.java index 92bdc9157ad..675790fefc9 100644 --- a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/ExtensibleTrustManager.java +++ b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/ExtensibleTrustManager.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/main/java/org/openhab/core/io/net/http/HttpClientFactory.java b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/HttpClientFactory.java index 318f2fbf5b2..f55e907812f 100644 --- a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/HttpClientFactory.java +++ b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/HttpClientFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/main/java/org/openhab/core/io/net/http/HttpClientInitializationException.java b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/HttpClientInitializationException.java index 495437a1e80..8a0a4d7f8ce 100644 --- a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/HttpClientInitializationException.java +++ b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/HttpClientInitializationException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/main/java/org/openhab/core/io/net/http/HttpRequestBuilder.java b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/HttpRequestBuilder.java index e492522e699..0662105e297 100644 --- a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/HttpRequestBuilder.java +++ b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/HttpRequestBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/main/java/org/openhab/core/io/net/http/HttpUtil.java b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/HttpUtil.java index 76deaab77a1..080e5cb422d 100644 --- a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/HttpUtil.java +++ b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/HttpUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -281,7 +281,7 @@ private static ProxyParams prepareProxyParams() { String proxyPortString = System.getProperty("http.proxyPort"); if (proxyPortString != null && !proxyPortString.isBlank()) { try { - proxyParams.proxyPort = Integer.valueOf(proxyPortString); + proxyParams.proxyPort = Integer.parseInt(proxyPortString); } catch (NumberFormatException e) { LOGGER.warn("'{}' is not a valid proxy port - using default port ({}) instead", proxyPortString, proxyParams.proxyPort); @@ -526,7 +526,8 @@ public static String guessContentTypeFromData(byte[] data) { * Check whether the content data is a JPEG file checking file start and end bytes. * {@link URLConnection#guessContentTypeFromStream(InputStream)} is wrong for some JPEG files. * - * @see https://en.wikipedia.org/wiki/JPEG#Syntax_and_structure + * @see JPEG Syntax and structure + * * @param data the data as buffer of bytes * @return true if the content is a JPEG file, false otherwise */ diff --git a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/PEMTrustManager.java b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/PEMTrustManager.java index f984422f91b..530f682b11f 100644 --- a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/PEMTrustManager.java +++ b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/PEMTrustManager.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -232,7 +232,7 @@ public boolean equals(@Nullable Object obj) { File certFile = new File(path); if (certFile.exists()) { try { - return new String(Files.readAllBytes(certFile.toPath()), StandardCharsets.UTF_8); + return Files.readString(certFile.toPath()); } catch (IOException e) { LoggerFactory.getLogger(PEMTrustManager.class).error("An unexpected IOException occurred: ", e); } diff --git a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/TlsCertificateProvider.java b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/TlsCertificateProvider.java index 7c0a82f9dce..cb96e0c2954 100644 --- a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/TlsCertificateProvider.java +++ b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/TlsCertificateProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/main/java/org/openhab/core/io/net/http/TlsProvider.java b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/TlsProvider.java index 42f54351b27..825e0575776 100644 --- a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/TlsProvider.java +++ b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/TlsProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/main/java/org/openhab/core/io/net/http/TlsTrustManagerProvider.java b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/TlsTrustManagerProvider.java index 67571600814..459d5355851 100644 --- a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/TlsTrustManagerProvider.java +++ b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/TlsTrustManagerProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/main/java/org/openhab/core/io/net/http/TrustAllTrustManager.java b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/TrustAllTrustManager.java index 3ff7d2392b1..30fd38325e5 100644 --- a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/TrustAllTrustManager.java +++ b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/TrustAllTrustManager.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/main/java/org/openhab/core/io/net/http/WebSocketFactory.java b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/WebSocketFactory.java index bd9dc197ec4..065a0467df1 100644 --- a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/WebSocketFactory.java +++ b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/WebSocketFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/main/java/org/openhab/core/io/net/http/internal/ExtensibleTrustManagerImpl.java b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/internal/ExtensibleTrustManagerImpl.java index 510e127b5d8..807451d6854 100644 --- a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/internal/ExtensibleTrustManagerImpl.java +++ b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/internal/ExtensibleTrustManagerImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/main/java/org/openhab/core/io/net/http/internal/TlsCertificateTrustManagerAdapter.java b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/internal/TlsCertificateTrustManagerAdapter.java index 54a926406b4..2656614d4d9 100644 --- a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/internal/TlsCertificateTrustManagerAdapter.java +++ b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/internal/TlsCertificateTrustManagerAdapter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/main/java/org/openhab/core/io/net/http/internal/TrustManagerUtil.java b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/internal/TrustManagerUtil.java index cb9dbb900bc..df22b52650f 100644 --- a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/internal/TrustManagerUtil.java +++ b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/internal/TrustManagerUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/main/java/org/openhab/core/io/net/http/internal/WebClientFactoryImpl.java b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/internal/WebClientFactoryImpl.java index 21b8ab051fd..367bed2afee 100644 --- a/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/internal/WebClientFactoryImpl.java +++ b/bundles/org.openhab.core.io.net/src/main/java/org/openhab/core/io/net/http/internal/WebClientFactoryImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/test/java/org/openhab/core/io/net/exec/ExecUtilTest.java b/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/exec/ExecUtilTest.java index cfcf9ac25bc..c4f23c4897b 100644 --- a/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/exec/ExecUtilTest.java +++ b/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/exec/ExecUtilTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/test/java/org/openhab/core/io/net/http/BaseHttpUtilTest.java b/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/BaseHttpUtilTest.java index 596a1d9f276..321903e4903 100644 --- a/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/BaseHttpUtilTest.java +++ b/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/BaseHttpUtilTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/test/java/org/openhab/core/io/net/http/HttpRequestBuilderTest.java b/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/HttpRequestBuilderTest.java index ba43f4042d6..6d250d9b2c0 100644 --- a/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/HttpRequestBuilderTest.java +++ b/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/HttpRequestBuilderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/test/java/org/openhab/core/io/net/http/HttpUtilTest.java b/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/HttpUtilTest.java index ff5be84e314..2230716c8cc 100644 --- a/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/HttpUtilTest.java +++ b/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/HttpUtilTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/test/java/org/openhab/core/io/net/http/internal/ExtensibleTrustManagerImplTest.java b/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/internal/ExtensibleTrustManagerImplTest.java index 4865e9d4c6d..c1523f3c8f2 100644 --- a/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/internal/ExtensibleTrustManagerImplTest.java +++ b/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/internal/ExtensibleTrustManagerImplTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.net/src/test/java/org/openhab/core/io/net/http/internal/WebClientFactoryImplTest.java b/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/internal/WebClientFactoryImplTest.java index af9080ade36..50113485f95 100644 --- a/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/internal/WebClientFactoryImplTest.java +++ b/bundles/org.openhab.core.io.net/src/test/java/org/openhab/core/io/net/http/internal/WebClientFactoryImplTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.audio/pom.xml b/bundles/org.openhab.core.io.rest.audio/pom.xml index f1bfc40a292..09c65bf887e 100644 --- a/bundles/org.openhab.core.io.rest.audio/pom.xml +++ b/bundles/org.openhab.core.io.rest.audio/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.rest.audio diff --git a/bundles/org.openhab.core.io.rest.audio/src/main/java/org/openhab/core/io/rest/audio/internal/AudioMapper.java b/bundles/org.openhab.core.io.rest.audio/src/main/java/org/openhab/core/io/rest/audio/internal/AudioMapper.java index 089885cf9eb..0bd0309eaa9 100644 --- a/bundles/org.openhab.core.io.rest.audio/src/main/java/org/openhab/core/io/rest/audio/internal/AudioMapper.java +++ b/bundles/org.openhab.core.io.rest.audio/src/main/java/org/openhab/core/io/rest/audio/internal/AudioMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.audio/src/main/java/org/openhab/core/io/rest/audio/internal/AudioResource.java b/bundles/org.openhab.core.io.rest.audio/src/main/java/org/openhab/core/io/rest/audio/internal/AudioResource.java index f7feb4a812d..aeb02927279 100644 --- a/bundles/org.openhab.core.io.rest.audio/src/main/java/org/openhab/core/io/rest/audio/internal/AudioResource.java +++ b/bundles/org.openhab.core.io.rest.audio/src/main/java/org/openhab/core/io/rest/audio/internal/AudioResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.audio/src/main/java/org/openhab/core/io/rest/audio/internal/AudioSinkDTO.java b/bundles/org.openhab.core.io.rest.audio/src/main/java/org/openhab/core/io/rest/audio/internal/AudioSinkDTO.java index 0793e4f76a4..d67a23d9dbd 100644 --- a/bundles/org.openhab.core.io.rest.audio/src/main/java/org/openhab/core/io/rest/audio/internal/AudioSinkDTO.java +++ b/bundles/org.openhab.core.io.rest.audio/src/main/java/org/openhab/core/io/rest/audio/internal/AudioSinkDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.audio/src/main/java/org/openhab/core/io/rest/audio/internal/AudioSourceDTO.java b/bundles/org.openhab.core.io.rest.audio/src/main/java/org/openhab/core/io/rest/audio/internal/AudioSourceDTO.java index e1dba5c4d31..38e2f714295 100644 --- a/bundles/org.openhab.core.io.rest.audio/src/main/java/org/openhab/core/io/rest/audio/internal/AudioSourceDTO.java +++ b/bundles/org.openhab.core.io.rest.audio/src/main/java/org/openhab/core/io/rest/audio/internal/AudioSourceDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.auth/pom.xml b/bundles/org.openhab.core.io.rest.auth/pom.xml index 853f0962658..06f7db1c750 100644 --- a/bundles/org.openhab.core.io.rest.auth/pom.xml +++ b/bundles/org.openhab.core.io.rest.auth/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.rest.auth diff --git a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/AnonymousUserSecurityContext.java b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/AnonymousUserSecurityContext.java index ec4a0fa4427..18fe0fa3cec 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/AnonymousUserSecurityContext.java +++ b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/AnonymousUserSecurityContext.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/AuthFilter.java b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/AuthFilter.java index 31fe5574f7a..1d7230bc8c1 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/AuthFilter.java +++ b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/AuthFilter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/AuthenticationSecurityContext.java b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/AuthenticationSecurityContext.java index 045c38a4515..8b068504950 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/AuthenticationSecurityContext.java +++ b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/AuthenticationSecurityContext.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/ExpiringUserSecurityContextCache.java b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/ExpiringUserSecurityContextCache.java index 5112d10e682..837468e724c 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/ExpiringUserSecurityContextCache.java +++ b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/ExpiringUserSecurityContextCache.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/JwtHelper.java b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/JwtHelper.java index c29bd4487ca..59adec3c31f 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/JwtHelper.java +++ b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/JwtHelper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.BufferedReader; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -72,7 +71,7 @@ public JwtHelper() { } } - private RsaJsonWebKey generateNewKey() throws JoseException, FileNotFoundException, IOException { + private RsaJsonWebKey generateNewKey() throws JoseException, IOException { RsaJsonWebKey newKey = RsaJwkGenerator.generateJwk(2048); File file = new File(KEY_FILE_PATH); @@ -84,7 +83,7 @@ private RsaJsonWebKey generateNewKey() throws JoseException, FileNotFoundExcepti return newKey; } - private RsaJsonWebKey loadOrGenerateKey() throws FileNotFoundException, JoseException, IOException { + private RsaJsonWebKey loadOrGenerateKey() throws JoseException, IOException { try (final BufferedReader reader = Files.newBufferedReader(Paths.get(KEY_FILE_PATH))) { return (RsaJsonWebKey) JsonWebKey.Factory.newJwk(reader.readLine()); } catch (IOException | JoseException e) { diff --git a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/JwtSecurityContext.java b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/JwtSecurityContext.java index 6b2fe0fed9f..1ce0f573f84 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/JwtSecurityContext.java +++ b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/JwtSecurityContext.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/RolesAllowedDynamicFeatureImpl.java b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/RolesAllowedDynamicFeatureImpl.java index a1746ea26c0..e2fbf13515e 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/RolesAllowedDynamicFeatureImpl.java +++ b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/RolesAllowedDynamicFeatureImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -45,7 +45,7 @@ * {@code javax.annotation.security.PermitAll} and {@code javax.annotation.security.DenyAll} * on resource methods and sub-resource methods. * - * Ported from {@link RolesAllowedDynamicFeature} with modifications. + * Ported from the Jersey {@code RolesAllowedDynamicFeature} class with modifications. * * @author Paul Sandoz - initial contribution * @author Martin Matula - initial contribution diff --git a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/TokenEndpointException.java b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/TokenEndpointException.java index 0fb733960a4..43cec5e7cff 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/TokenEndpointException.java +++ b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/TokenEndpointException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +19,8 @@ * An exception when the token endpoint encounters an error and must return an error response, according to RFC 6749 * Section 5.2. * - * {@linkplain https://tools.ietf.org/html/rfc6749#section-5.2} + * @see RFC 6749: Issuing an Access Token - Error + * Response * * @author Yannick Schaus - initial contribution */ diff --git a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/TokenResource.java b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/TokenResource.java index 51f24f0672e..5807f10ebfa 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/TokenResource.java +++ b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/TokenResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/TokenResponseDTO.java b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/TokenResponseDTO.java index e48c39d8b8f..a79c3449315 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/TokenResponseDTO.java +++ b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/TokenResponseDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,8 @@ /** * A DTO object for a successful token endpoint response, as per RFC 6749, Section 5.1. * - * {@linkplain https://tools.ietf.org/html/rfc6749#section-5.1} + * @see RFC 6749: Issuing an Access Token - + * Successful Response * * @author Yannick Schaus - initial contribution */ diff --git a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/TokenResponseErrorDTO.java b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/TokenResponseErrorDTO.java index 08516e3a623..7474ae642b4 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/TokenResponseErrorDTO.java +++ b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/TokenResponseErrorDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,8 @@ /** * A DTO object for an unsuccessful token endpoint response, as per RFC 6749, Section 5.2. * - * {@linkplain https://tools.ietf.org/html/rfc6749#section-5.2} + * @see RFC 6749: Issuing an Access Token - Error + * Response * * @author Yannick Schaus - initial contribution */ diff --git a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/UserApiTokenDTO.java b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/UserApiTokenDTO.java index 769f48da995..0ba961fb287 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/UserApiTokenDTO.java +++ b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/UserApiTokenDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/UserDTO.java b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/UserDTO.java index 773d8a24d09..4895ef0fa96 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/UserDTO.java +++ b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/UserDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/UserSecurityContext.java b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/UserSecurityContext.java index 3e43aea40a5..3e8260fe9ee 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/UserSecurityContext.java +++ b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/UserSecurityContext.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 @@ public class UserSecurityContext implements AuthenticationSecurityContext { * Constructs a security context from an instance of {@link User} * * @param user the user - * @param the related {@link Authentication} + * @param authentication the related {@link Authentication} * @param authenticationScheme the scheme that was used to authenticate the user, e.g. "Basic" */ public UserSecurityContext(User user, Authentication authentication, String authenticationScheme) { diff --git a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/UserSessionDTO.java b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/UserSessionDTO.java index 083466659ad..cfcc92eb738 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/UserSessionDTO.java +++ b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/UserSessionDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.auth/src/test/java/org/openhab/core/io/rest/auth/AuthFilterTest.java b/bundles/org.openhab.core.io.rest.auth/src/test/java/org/openhab/core/io/rest/auth/AuthFilterTest.java index 2f5bca9c806..95a31ec1136 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/test/java/org/openhab/core/io/rest/auth/AuthFilterTest.java +++ b/bundles/org.openhab.core.io.rest.auth/src/test/java/org/openhab/core/io/rest/auth/AuthFilterTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.auth/src/test/java/org/openhab/core/io/rest/auth/internal/ExpiringUserSecurityContextCacheTest.java b/bundles/org.openhab.core.io.rest.auth/src/test/java/org/openhab/core/io/rest/auth/internal/ExpiringUserSecurityContextCacheTest.java index a425dcba22e..53886462108 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/test/java/org/openhab/core/io/rest/auth/internal/ExpiringUserSecurityContextCacheTest.java +++ b/bundles/org.openhab.core.io.rest.auth/src/test/java/org/openhab/core/io/rest/auth/internal/ExpiringUserSecurityContextCacheTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/pom.xml b/bundles/org.openhab.core.io.rest.core/pom.xml index e829c11cd58..9fe8a20c134 100644 --- a/bundles/org.openhab.core.io.rest.core/pom.xml +++ b/bundles/org.openhab.core.io.rest.core/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.rest.core @@ -35,6 +35,11 @@ org.openhab.core.config.discovery ${project.version} + + org.openhab.core.bundles + org.openhab.core.config.discovery.addon + ${project.version} + org.openhab.core.bundles org.openhab.core.io.rest diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/config/ConfigurationService.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/config/ConfigurationService.java index 7ea4850597e..b3792c51a81 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/config/ConfigurationService.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/config/ConfigurationService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/config/EnrichedConfigDescriptionDTOMapper.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/config/EnrichedConfigDescriptionDTOMapper.java index edc6871ba2d..17efe377a07 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/config/EnrichedConfigDescriptionDTOMapper.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/config/EnrichedConfigDescriptionDTOMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/config/EnrichedConfigDescriptionParameterDTO.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/config/EnrichedConfigDescriptionParameterDTO.java index 754aa5739fe..88afee855e6 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/config/EnrichedConfigDescriptionParameterDTO.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/config/EnrichedConfigDescriptionParameterDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/GsonMessageBodyReader.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/GsonMessageBodyReader.java index 523b367222f..f41af4276de 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/GsonMessageBodyReader.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/GsonMessageBodyReader.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/GsonMessageBodyWriter.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/GsonMessageBodyWriter.java index 11da99be169..3bf8d8645cf 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/GsonMessageBodyWriter.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/GsonMessageBodyWriter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/JSONResponseExceptionMapper.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/JSONResponseExceptionMapper.java index f86681ccb1f..3939a1f026c 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/JSONResponseExceptionMapper.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/JSONResponseExceptionMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,6 +14,7 @@ import java.io.IOException; +import javax.ws.rs.ClientErrorException; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; @@ -50,6 +51,11 @@ public class JSONResponseExceptionMapper implements ExceptionMapper { logger.debug("Failed writing HTTP response, since other side closed the connection", e); // Returning null results in a Response.Status.NO_CONTENT response. return null; + } else if (e instanceof ClientErrorException cee) { + // we catch this exception to avoid confusion errors in the log file, since this is not any error situation + // see https://github.com/openhab/openhab-distro/issues/1616 + logger.debug("Requested resource not (yet) found", cee); + return cee.getResponse(); } else { logger.error("Unexpected exception occurred while processing REST request.", e); return delegate.toResponse(e); diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/MediaTypeExtension.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/MediaTypeExtension.java index a206ca3d547..c1421092d24 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/MediaTypeExtension.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/MediaTypeExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/PlainMessageBodyReader.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/PlainMessageBodyReader.java index 399fc2bac83..13d51b8ce00 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/PlainMessageBodyReader.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/PlainMessageBodyReader.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/PlainMessageBodyWriter.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/PlainMessageBodyWriter.java index 4a6e35622cf..0eaa1b63694 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/PlainMessageBodyWriter.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/PlainMessageBodyWriter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/addons/AddonResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/addons/AddonResource.java index b2b4f8beebf..fa5eadf97f7 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/addons/AddonResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/addons/AddonResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -56,6 +56,7 @@ import org.openhab.core.config.core.ConfigDescriptionRegistry; import org.openhab.core.config.core.ConfigUtil; import org.openhab.core.config.core.Configuration; +import org.openhab.core.config.discovery.addon.AddonSuggestionService; import org.openhab.core.events.Event; import org.openhab.core.events.EventPublisher; import org.openhab.core.io.rest.JSONResponse; @@ -120,6 +121,7 @@ public class AddonResource implements RESTResource { private final ConfigurationService configurationService; private final AddonInfoRegistry addonInfoRegistry; private final ConfigDescriptionRegistry configDescriptionRegistry; + private final AddonSuggestionService addonSuggestionService; private @Context @NonNullByDefault({}) UriInfo uriInfo; @@ -127,12 +129,14 @@ public class AddonResource implements RESTResource { public AddonResource(final @Reference EventPublisher eventPublisher, final @Reference LocaleService localeService, final @Reference ConfigurationService configurationService, final @Reference AddonInfoRegistry addonInfoRegistry, - final @Reference ConfigDescriptionRegistry configDescriptionRegistry) { + final @Reference ConfigDescriptionRegistry configDescriptionRegistry, + final @Reference AddonSuggestionService addonSuggestionService) { this.eventPublisher = eventPublisher; this.localeService = localeService; this.configurationService = configurationService; this.addonInfoRegistry = addonInfoRegistry; this.configDescriptionRegistry = configDescriptionRegistry; + this.addonSuggestionService = addonSuggestionService; } @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) @@ -178,6 +182,19 @@ public Response getServices( return Response.ok(new Stream2JSONInputStream(addonTypeStream)).build(); } + @GET + @Path("/suggestions") + @Produces(MediaType.APPLICATION_JSON) + @Operation(operationId = "getSuggestedAddons", summary = "Get suggested add-ons to be installed.", responses = { + @ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Addon.class)))), }) + public Response getSuggestions( + @HeaderParam("Accept-Language") @Parameter(description = "language") @Nullable String language) { + logger.debug("Received HTTP GET request at '{}'", uriInfo.getPath()); + Locale locale = localeService.getLocale(language); + return Response.ok(new Stream2JSONInputStream(addonSuggestionService.getSuggestedAddons(locale).stream())) + .build(); + } + @GET @Path("/types") @Produces(MediaType.APPLICATION_JSON) @@ -236,9 +253,10 @@ public Response getById( public Response installAddon(final @PathParam("addonId") @Parameter(description = "addon ID") String addonId, @QueryParam("serviceId") @Parameter(description = "service ID") @Nullable String serviceId) { AddonService addonService = (serviceId != null) ? getServiceById(serviceId) : getDefaultService(); - if (addonService == null) { + if (addonService == null || addonService.getAddon(addonId, null) == null) { return Response.status(HttpStatus.NOT_FOUND_404).build(); } + ThreadPoolManager.getPool(THREAD_POOL_NAME).submit(() -> { try { addonService.install(addonId); @@ -277,7 +295,7 @@ public Response installAddonByURL( public Response uninstallAddon(final @PathParam("addonId") @Parameter(description = "addon ID") String addonId, @QueryParam("serviceId") @Parameter(description = "service ID") @Nullable String serviceId) { AddonService addonService = (serviceId != null) ? getServiceById(serviceId) : getDefaultService(); - if (addonService == null) { + if (addonService == null || addonService.getAddon(addonId, null) == null) { return Response.status(HttpStatus.NOT_FOUND_404).build(); } ThreadPoolManager.getPool(THREAD_POOL_NAME).submit(() -> { diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/addons/AddonServiceDTO.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/addons/AddonServiceDTO.java index bd8214b324b..dc2578f8489 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/addons/AddonServiceDTO.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/addons/AddonServiceDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/channel/ChannelTypeResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/channel/ChannelTypeResource.java index 46dd33c3ac9..4d49ea77e2c 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/channel/ChannelTypeResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/channel/ChannelTypeResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -175,9 +175,7 @@ public Response getLinkableItemTypes( for (ProfileType profileType : profileTypeRegistry.getProfileTypes()) { if (profileType instanceof TriggerProfileType type) { if (type.getSupportedChannelTypeUIDs().contains(ctUID)) { - for (String itemType : profileType.getSupportedItemTypes()) { - result.add(itemType); - } + result.addAll(profileType.getSupportedItemTypes()); } } } diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/config/ConfigDescriptionResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/config/ConfigDescriptionResource.java index 3f0579f1495..3633c451fcf 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/config/ConfigDescriptionResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/config/ConfigDescriptionResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/discovery/DiscoveryResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/discovery/DiscoveryResource.java index 53c5deeecdc..83a7fb640db 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/discovery/DiscoveryResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/discovery/DiscoveryResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/discovery/InboxResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/discovery/InboxResource.java index 42f65c9c227..6c1ef8e52de 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/discovery/InboxResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/discovery/InboxResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -116,7 +116,7 @@ public Response approve( ThingUID thingUIDObject = new ThingUID(thingUID); String notEmptyLabel = label != null && !label.isEmpty() ? label : null; String notEmptyNewThingId = newThingId != null && !newThingId.isEmpty() ? newThingId : null; - Thing thing = null; + Thing thing; try { thing = inbox.approve(thingUIDObject, notEmptyLabel, notEmptyNewThingId); } catch (IllegalArgumentException e) { diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/item/ItemResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/item/ItemResource.java index ccc7936c1b3..8aaa7e3700c 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/item/ItemResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/item/ItemResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -42,7 +42,6 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; -import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.CacheControl; import javax.ws.rs.core.Context; import javax.ws.rs.core.HttpHeaders; @@ -272,6 +271,7 @@ public Response getItems(final @Context UriInfo uriInfo, final @Context HttpHead "name,label,type,groupType,function,category,editable,groupNames,link,tags,metadata,commandDescription,stateDescription"); CacheControl cc = new CacheControl(); + cc.setNoCache(true); cc.setMustRevalidate(true); cc.setPrivate(true); return Response.ok(new Stream2JSONInputStream(itemStream)).lastModified(lastModifiedDate).cacheControl(cc) @@ -485,7 +485,7 @@ public Response postItemCommand(@PathParam("itemname") @Parameter(description = return Response.status(Status.BAD_REQUEST).build(); } } else { - throw new WebApplicationException(404); + return getItemNotFoundResponse(itemname); } } @@ -524,7 +524,7 @@ public Response addMember(@PathParam("itemName") @Parameter(description = "item return Response.ok(null, MediaType.TEXT_PLAIN).build(); } catch (ItemNotFoundException e) { - return Response.status(Status.NOT_FOUND).build(); + return getItemNotFoundResponse(itemName); } } @@ -563,7 +563,7 @@ public Response removeMember(@PathParam("itemName") @Parameter(description = "it return Response.ok(null, MediaType.TEXT_PLAIN).build(); } catch (ItemNotFoundException e) { - return Response.status(Status.NOT_FOUND).build(); + return getItemNotFoundResponse(itemName); } } diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/item/MetadataSelectorMatcher.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/item/MetadataSelectorMatcher.java index b774f5a075e..104a53b5415 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/item/MetadataSelectorMatcher.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/item/MetadataSelectorMatcher.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -57,7 +57,7 @@ public Set filterNamespaces(@Nullable String namespaceSelector, @Nullabl } else { Set originalNamespaces = Arrays.stream(namespaceSelector.split(",")) // .filter(n -> !metadataRegistry.isInternalNamespace(n)) // - .map(n -> n.trim()) // + .map(String::trim) // .collect(Collectors.toSet()); Set allMetadataNamespaces = metadataRegistry.getAll().stream() // @@ -65,7 +65,7 @@ public Set filterNamespaces(@Nullable String namespaceSelector, @Nullabl .distinct() // .collect(Collectors.toSet()); - String namespacePattern = originalNamespaces.stream().collect(Collectors.joining("|")); + String namespacePattern = String.join("|", originalNamespaces); Pattern pattern = Pattern.compile("(" + namespacePattern + ")$"); @@ -78,8 +78,7 @@ public Set filterNamespaces(@Nullable String namespaceSelector, @Nullabl result.addAll(metadataNamespaces); // filter all name spaces which do not match the UID segment pattern (this will be the regex tokens): - return result.stream().filter(namespace -> namespace.matches(AbstractUID.SEGMENT_PATTERN)) - .collect(Collectors.toSet()); + return result.stream().filter(AbstractUID::isValid).collect(Collectors.toSet()); } } } diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/link/ItemChannelLinkResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/link/ItemChannelLinkResource.java index ab158eb2380..0935d636692 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/link/ItemChannelLinkResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/link/ItemChannelLinkResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/persistence/PersistenceResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/persistence/PersistenceResource.java index fe0f01a6af0..ddfdc061940 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/persistence/PersistenceResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/persistence/PersistenceResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -55,6 +55,7 @@ import org.openhab.core.persistence.HistoricItem; import org.openhab.core.persistence.ModifiablePersistenceService; import org.openhab.core.persistence.PersistenceItemInfo; +import org.openhab.core.persistence.PersistenceManager; import org.openhab.core.persistence.PersistenceService; import org.openhab.core.persistence.PersistenceServiceRegistry; import org.openhab.core.persistence.QueryablePersistenceService; @@ -121,6 +122,7 @@ public class PersistenceResource implements RESTResource { private final ItemRegistry itemRegistry; private final LocaleService localeService; private final PersistenceServiceRegistry persistenceServiceRegistry; + private final PersistenceManager persistenceManager; private final PersistenceServiceConfigurationRegistry persistenceServiceConfigurationRegistry; private final ManagedPersistenceServiceConfigurationProvider managedPersistenceServiceConfigurationProvider; private final TimeZoneProvider timeZoneProvider; @@ -130,12 +132,14 @@ public PersistenceResource( // final @Reference ItemRegistry itemRegistry, // final @Reference LocaleService localeService, final @Reference PersistenceServiceRegistry persistenceServiceRegistry, + final @Reference PersistenceManager persistenceManager, final @Reference PersistenceServiceConfigurationRegistry persistenceServiceConfigurationRegistry, final @Reference ManagedPersistenceServiceConfigurationProvider managedPersistenceServiceConfigurationProvider, final @Reference TimeZoneProvider timeZoneProvider) { this.itemRegistry = itemRegistry; this.localeService = localeService; this.persistenceServiceRegistry = persistenceServiceRegistry; + this.persistenceManager = persistenceManager; this.persistenceServiceConfigurationRegistry = persistenceServiceConfigurationRegistry; this.managedPersistenceServiceConfigurationProvider = managedPersistenceServiceConfigurationProvider; this.timeZoneProvider = timeZoneProvider; @@ -518,7 +522,7 @@ private Response getServiceItemList(@Nullable String serviceId) { private Response deletePersistenceItemData(@Nullable String serviceId, String itemName, @Nullable String timeBegin, @Nullable String timeEnd) { // For deleting, we must specify a service id - don't use the default service - if (serviceId == null || serviceId.length() == 0) { + if (serviceId == null || serviceId.isEmpty()) { logger.debug("Persistence service must be specified for delete operations."); return JSONResponse.createErrorResponse(Status.BAD_REQUEST, "Persistence service must be specified for delete operations."); @@ -598,7 +602,7 @@ private Response putItemState(@Nullable String serviceId, String itemName, Strin } ZonedDateTime dateTime = null; - if (time != null && time.length() != 0) { + if (time != null && !time.isEmpty()) { dateTime = convertTime(time); } if (dateTime == null || dateTime.toEpochSecond() == 0) { @@ -608,6 +612,9 @@ private Response putItemState(@Nullable String serviceId, String itemName, Strin ModifiablePersistenceService mService = (ModifiablePersistenceService) service; mService.store(item, dateTime, state); + + persistenceManager.handleExternalPersistenceDataChange(mService, item); + return Response.status(Status.OK).build(); } } diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/profile/ProfileTypeResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/profile/ProfileTypeResource.java index 3e202346890..92ca7637555 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/profile/ProfileTypeResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/profile/ProfileTypeResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -116,7 +116,7 @@ protected Stream getProfileTypes(@Nullable Locale locale, @Nulla @Nullable String itemType) { return profileTypeRegistry.getProfileTypes(locale).stream().filter(matchesChannelUID(channelTypeUID, locale)) .filter(matchesItemType(itemType)).sorted(Comparator.comparing(ProfileType::getLabel)) - .map(profileType -> ProfileTypeDTOMapper.map(profileType)); + .map(ProfileTypeDTOMapper::map); } private Predicate matchesChannelUID(@Nullable String channelTypeUID, @Nullable Locale locale) { diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/service/ConfigurableServiceResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/service/ConfigurableServiceResource.java index 103185afa1f..aca81250439 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/service/ConfigurableServiceResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/service/ConfigurableServiceResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -296,7 +296,7 @@ private List getServicesByFilter(String filter, Locale l for (ServiceReference serviceReference : serviceReferences) { String id = getServiceId(serviceReference); ConfigurableService configurableService = ConfigurableServiceUtil - .asConfigurableService((key) -> serviceReference.getProperty(key)); + .asConfigurableService(serviceReference::getProperty); String defaultLabel = configurableService.label(); if (defaultLabel.isEmpty()) { // for multi context services the label can be changed and must be read @@ -336,7 +336,7 @@ private List getServicesByFilter(String filter, Locale l if (refs != null && refs.length > 0) { ConfigurableService configurableService = ConfigurableServiceUtil - .asConfigurableService((key) -> refs[0].getProperty(key)); + .asConfigurableService(key -> refs[0].getProperty(key)); configDescriptionURI = configurableService.description_uri(); } } catch (InvalidSyntaxException e) { diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/tag/EnrichedSemanticTagDTO.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/tag/EnrichedSemanticTagDTO.java index f19d33f6802..b13bdd4fd9e 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/tag/EnrichedSemanticTagDTO.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/tag/EnrichedSemanticTagDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/tag/TagResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/tag/TagResource.java index 4e97419e0d9..a4d42931c5b 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/tag/TagResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/tag/TagResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -133,6 +133,7 @@ public Response getTags(final @Context Request request, final @Context UriInfo u } CacheControl cc = new CacheControl(); + cc.setNoCache(true); cc.setMustRevalidate(true); cc.setPrivate(true); @@ -165,6 +166,7 @@ public Response getTagAndSubTags(final @Context Request request, } CacheControl cc = new CacheControl(); + cc.setNoCache(true); cc.setMustRevalidate(true); cc.setPrivate(true); diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/thing/ThingResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/thing/ThingResource.java index 440a6c7708e..d103ba8cf67 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/thing/ThingResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/thing/ThingResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -328,6 +328,7 @@ public Response getAll(@Context Request request, } CacheControl cc = new CacheControl(); + cc.setNoCache(true); cc.setMustRevalidate(true); cc.setPrivate(true); thingStream = dtoMapper.limitToFields(thingStream, "UID,label,bridgeUID,thingTypeUID,location,editable"); @@ -605,7 +606,7 @@ public Response setEnabled( return getThingNotFoundResponse(thingUID); } - thingManager.setEnabled(thingUIDObject, Boolean.valueOf(enabled)); + thingManager.setEnabled(thingUIDObject, Boolean.parseBoolean(enabled)); // everything went well return getThingResponse(Status.OK, thing, locale, null); diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/thing/ThingTypeResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/thing/ThingTypeResource.java index c52ed6e6cec..f80dfea8f48 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/thing/ThingTypeResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/thing/ThingTypeResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/item/EnrichedGroupItemDTO.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/item/EnrichedGroupItemDTO.java index 4604bf4aa74..fafc88ab2fe 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/item/EnrichedGroupItemDTO.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/item/EnrichedGroupItemDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/item/EnrichedItemDTO.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/item/EnrichedItemDTO.java index 62f6aaf906f..d1a64e7595d 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/item/EnrichedItemDTO.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/item/EnrichedItemDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/item/EnrichedItemDTOMapper.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/item/EnrichedItemDTOMapper.java index 94a4b85c122..c8c1272cbf1 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/item/EnrichedItemDTOMapper.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/item/EnrichedItemDTOMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -105,10 +105,10 @@ private static EnrichedItemDTO map(Item item, ItemDTO itemDTO, boolean drillDown for (Item member : groupItem.getMembers()) { if (parents.contains(member)) { LOGGER.error( - "Recursive group membership found: {} is both, a direct or indirect parent and a child of {}.", + "Recursive group membership found: {} is a member of {}, but it is also one of its ancestors.", member.getName(), groupItem.getName()); } else if (itemFilter == null || itemFilter.test(member)) { - members.add(mapRecursive(member, itemFilter, uriBuilder, locale, parents)); + members.add(mapRecursive(member, itemFilter, uriBuilder, locale, new ArrayList<>(parents))); } } memberDTOs = members.toArray(new EnrichedItemDTO[0]); diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/link/EnrichedItemChannelLinkDTO.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/link/EnrichedItemChannelLinkDTO.java index 3403cedf5d9..9f594556ff1 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/link/EnrichedItemChannelLinkDTO.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/link/EnrichedItemChannelLinkDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/link/EnrichedItemChannelLinkDTOMapper.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/link/EnrichedItemChannelLinkDTOMapper.java index 440f8121494..8283bb4a3b6 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/link/EnrichedItemChannelLinkDTOMapper.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/link/EnrichedItemChannelLinkDTOMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/persistence/ItemHistoryListDTO.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/persistence/ItemHistoryListDTO.java index 523aa9cd185..dda000af400 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/persistence/ItemHistoryListDTO.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/persistence/ItemHistoryListDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/service/ConfigurableServiceDTO.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/service/ConfigurableServiceDTO.java index 89a0b6718cb..3341615704a 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/service/ConfigurableServiceDTO.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/service/ConfigurableServiceDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/thing/EnrichedChannelDTO.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/thing/EnrichedChannelDTO.java index e0ca44efb52..89b997fcbb1 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/thing/EnrichedChannelDTO.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/thing/EnrichedChannelDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/thing/EnrichedThingDTO.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/thing/EnrichedThingDTO.java index c17ce4df1b4..00b03d43387 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/thing/EnrichedThingDTO.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/thing/EnrichedThingDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/main/java/org/openhab/core/io/rest/core/thing/EnrichedThingDTOMapper.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/thing/EnrichedThingDTOMapper.java index 86c654f06a5..3859b07f2d0 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/thing/EnrichedThingDTOMapper.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/thing/EnrichedThingDTOMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/test/java/org/openhab/core/io/rest/core/config/EnrichedConfigDescriptionDTOMapperTest.java b/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/config/EnrichedConfigDescriptionDTOMapperTest.java index 33d0c6e8041..5fdf1e8eed3 100644 --- a/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/config/EnrichedConfigDescriptionDTOMapperTest.java +++ b/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/config/EnrichedConfigDescriptionDTOMapperTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/channel/ChannelTypeResourceTest.java b/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/channel/ChannelTypeResourceTest.java index 0afaa6c50c9..c3b91a5a6bd 100644 --- a/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/channel/ChannelTypeResourceTest.java +++ b/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/channel/ChannelTypeResourceTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/config/ConfigDescriptionResourceTest.java b/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/config/ConfigDescriptionResourceTest.java index 9136799d35a..3e3bc044712 100644 --- a/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/config/ConfigDescriptionResourceTest.java +++ b/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/config/ConfigDescriptionResourceTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/item/MetadataSelectorMatcherTest.java b/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/item/MetadataSelectorMatcherTest.java index 989b6aabc3c..23bc76b6fb7 100644 --- a/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/item/MetadataSelectorMatcherTest.java +++ b/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/item/MetadataSelectorMatcherTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/link/ItemChannelLinkResourceTest.java b/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/link/ItemChannelLinkResourceTest.java index 2d8fdb694ab..23ae740adbc 100644 --- a/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/link/ItemChannelLinkResourceTest.java +++ b/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/link/ItemChannelLinkResourceTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/persistence/PersistenceResourceTest.java b/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/persistence/PersistenceResourceTest.java index 7ad448a9ff2..b2fd7b38ef0 100644 --- a/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/persistence/PersistenceResourceTest.java +++ b/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/persistence/PersistenceResourceTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -24,21 +24,29 @@ import java.util.ArrayList; import java.util.List; +import javax.ws.rs.core.HttpHeaders; + import org.eclipse.jdt.annotation.NonNullByDefault; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import org.openhab.core.i18n.TimeZoneProvider; import org.openhab.core.io.rest.LocaleService; +import org.openhab.core.items.Item; +import org.openhab.core.items.ItemNotFoundException; import org.openhab.core.items.ItemRegistry; +import org.openhab.core.library.items.NumberItem; import org.openhab.core.library.types.OnOffType; import org.openhab.core.persistence.HistoricItem; +import org.openhab.core.persistence.ModifiablePersistenceService; import org.openhab.core.persistence.PersistenceServiceRegistry; -import org.openhab.core.persistence.QueryablePersistenceService; import org.openhab.core.persistence.dto.ItemHistoryDTO; import org.openhab.core.persistence.dto.ItemHistoryDTO.HistoryDataBean; +import org.openhab.core.persistence.internal.PersistenceManagerImpl; import org.openhab.core.persistence.registry.ManagedPersistenceServiceConfigurationProvider; import org.openhab.core.persistence.registry.PersistenceServiceConfigurationRegistry; import org.openhab.core.types.State; @@ -49,6 +57,7 @@ * @author Stefan Triller - Initial contribution */ @ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) @NonNullByDefault public class PersistenceResourceTest { @@ -60,6 +69,8 @@ public class PersistenceResourceTest { private @Mock @NonNullByDefault({}) ItemRegistry itemRegistryMock; private @Mock @NonNullByDefault({}) LocaleService localeServiceMock; private @Mock @NonNullByDefault({}) PersistenceServiceRegistry persistenceServiceRegistryMock; + private @Mock @NonNullByDefault({}) ModifiablePersistenceService pServiceMock; + private @Mock @NonNullByDefault({}) PersistenceManagerImpl persistenceManagerMock; private @Mock @NonNullByDefault({}) PersistenceServiceConfigurationRegistry persistenceServiceConfigurationRegistryMock; private @Mock @NonNullByDefault({}) ManagedPersistenceServiceConfigurationProvider managedPersistenceServiceConfigurationProviderMock; private @Mock @NonNullByDefault({}) TimeZoneProvider timeZoneProviderMock; @@ -67,8 +78,8 @@ public class PersistenceResourceTest { @BeforeEach public void beforeEach() { pResource = new PersistenceResource(itemRegistryMock, localeServiceMock, persistenceServiceRegistryMock, - persistenceServiceConfigurationRegistryMock, managedPersistenceServiceConfigurationProviderMock, - timeZoneProviderMock); + persistenceManagerMock, persistenceServiceConfigurationRegistryMock, + managedPersistenceServiceConfigurationProviderMock, timeZoneProviderMock); int startValue = 2016; int endValue = 2018; @@ -97,10 +108,9 @@ public String getName() { }); } - QueryablePersistenceService pService = mock(QueryablePersistenceService.class); - when(pService.query(any())).thenReturn(items); + when(pServiceMock.query(any())).thenReturn(items); - when(persistenceServiceRegistryMock.get(PERSISTENCE_SERVICE_ID)).thenReturn(pService); + when(persistenceServiceRegistryMock.get(PERSISTENCE_SERVICE_ID)).thenReturn(pServiceMock); when(timeZoneProviderMock.getTimeZone()).thenReturn(ZoneId.systemDefault()); } @@ -142,4 +152,16 @@ public void testGetPersistenceItemDataWithBoundery() { assertThat(Integer.parseInt(dto.datapoints), is(7)); assertThat(dto.data, hasSize(7)); } + + @Test + public void testPutPersistenceItemData() throws ItemNotFoundException { + HttpHeaders headersMock = mock(HttpHeaders.class); + Item item = new NumberItem("itemName"); + when(itemRegistryMock.getItem("itemName")).thenReturn(item); + + pResource.httpPutPersistenceItemData(headersMock, PERSISTENCE_SERVICE_ID, "itemName", + "2024-02-01T00:00:00.000Z", "0"); + + verify(persistenceManagerMock).handleExternalPersistenceDataChange(eq(pServiceMock), eq(item)); + } } diff --git a/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/item/EnrichedItemDTOMapperTest.java b/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/item/EnrichedItemDTOMapperTest.java index 9b022f92197..85af584aa56 100644 --- a/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/item/EnrichedItemDTOMapperTest.java +++ b/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/item/EnrichedItemDTOMapperTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 void testDirectRecursiveMembershipDoesNotThrowStackOverflowException() { assertDoesNotThrow(() -> EnrichedItemDTOMapper.map(groupItem1, true, null, null, null)); assertLogMessage(EnrichedItemDTOMapper.class, LogLevel.ERROR, - "Recursive group membership found: group1 is both, a direct or indirect parent and a child of group2."); + "Recursive group membership found: group1 is a member of group2, but it is also one of its ancestors."); } @Test @@ -111,7 +111,7 @@ public void testIndirectRecursiveMembershipDoesNotThrowStackOverflowException() assertDoesNotThrow(() -> EnrichedItemDTOMapper.map(groupItem1, true, null, null, null)); assertLogMessage(EnrichedItemDTOMapper.class, LogLevel.ERROR, - "Recursive group membership found: group1 is both, a direct or indirect parent and a child of group3."); + "Recursive group membership found: group1 is a member of group3, but it is also one of its ancestors."); } @Test @@ -128,4 +128,19 @@ public void testDuplicateMembershipOfPlainItemsDoesNotTriggerWarning() { assertNoLogMessage(EnrichedItemDTOMapper.class); } + + @Test + public void testDuplicateMembershipOfGroupItemsDoesNotTriggerWarning() { + GroupItem groupItem1 = new GroupItem("group1"); + GroupItem groupItem2 = new GroupItem("group2"); + GroupItem groupItem3 = new GroupItem("group3"); + + groupItem1.addMember(groupItem2); + groupItem1.addMember(groupItem3); + groupItem2.addMember(groupItem3); + + EnrichedItemDTOMapper.map(groupItem1, true, null, null, null); + + assertNoLogMessage(EnrichedItemDTOMapper.class); + } } diff --git a/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/thing/EnrichedThingDTOMapperTest.java b/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/thing/EnrichedThingDTOMapperTest.java index ccdcd1e03d7..db4011a97a4 100644 --- a/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/thing/EnrichedThingDTOMapperTest.java +++ b/bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/thing/EnrichedThingDTOMapperTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.log/pom.xml b/bundles/org.openhab.core.io.rest.log/pom.xml index 9cf4c1437c6..1c5183a9ee4 100644 --- a/bundles/org.openhab.core.io.rest.log/pom.xml +++ b/bundles/org.openhab.core.io.rest.log/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.rest.log diff --git a/bundles/org.openhab.core.io.rest.log/src/main/java/org/openhab/core/io/rest/log/internal/LogConstants.java b/bundles/org.openhab.core.io.rest.log/src/main/java/org/openhab/core/io/rest/log/internal/LogConstants.java index 7feea8fb1c0..20ac2c130c3 100644 --- a/bundles/org.openhab.core.io.rest.log/src/main/java/org/openhab/core/io/rest/log/internal/LogConstants.java +++ b/bundles/org.openhab.core.io.rest.log/src/main/java/org/openhab/core/io/rest/log/internal/LogConstants.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.log/src/main/java/org/openhab/core/io/rest/log/internal/LogHandler.java b/bundles/org.openhab.core.io.rest.log/src/main/java/org/openhab/core/io/rest/log/internal/LogHandler.java index eb80ec9a13b..8f457092472 100644 --- a/bundles/org.openhab.core.io.rest.log/src/main/java/org/openhab/core/io/rest/log/internal/LogHandler.java +++ b/bundles/org.openhab.core.io.rest.log/src/main/java/org/openhab/core/io/rest/log/internal/LogHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 class LogHandler implements RESTResource { /** * Container for a log message */ - public class LogMessage { + public static class LogMessage { public long timestamp; public @Nullable String severity; public @Nullable URL url; diff --git a/bundles/org.openhab.core.io.rest.mdns/pom.xml b/bundles/org.openhab.core.io.rest.mdns/pom.xml index 79bb6fc31d3..6f26eab71cf 100644 --- a/bundles/org.openhab.core.io.rest.mdns/pom.xml +++ b/bundles/org.openhab.core.io.rest.mdns/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.rest.mdns diff --git a/bundles/org.openhab.core.io.rest.mdns/src/main/java/org/openhab/core/io/rest/mdns/internal/MDNSAnnouncer.java b/bundles/org.openhab.core.io.rest.mdns/src/main/java/org/openhab/core/io/rest/mdns/internal/MDNSAnnouncer.java index bcd8cb5e406..47bbfc3d5cb 100644 --- a/bundles/org.openhab.core.io.rest.mdns/src/main/java/org/openhab/core/io/rest/mdns/internal/MDNSAnnouncer.java +++ b/bundles/org.openhab.core.io.rest.mdns/src/main/java/org/openhab/core/io/rest/mdns/internal/MDNSAnnouncer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 ServiceDescription getDefaultServiceDescription() { private ServiceDescription getSSLServiceDescription() { ServiceDescription description = getDefaultServiceDescription(); description.serviceType = "_" + mdnsName + "-server-ssl._tcp.local."; - description.serviceName = "" + mdnsName + "-ssl"; + description.serviceName = mdnsName + "-ssl"; description.servicePort = httpSSLPort; return description; } diff --git a/bundles/org.openhab.core.io.rest.sitemap/pom.xml b/bundles/org.openhab.core.io.rest.sitemap/pom.xml index 8a2b5ec5065..70cfd881a58 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/pom.xml +++ b/bundles/org.openhab.core.io.rest.sitemap/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.rest.sitemap diff --git a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/SitemapSubscriptionService.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/SitemapSubscriptionService.java index d614ae569b6..c93f21b172d 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/SitemapSubscriptionService.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/SitemapSubscriptionService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +179,7 @@ public void removeSubscription(String subscriptionId) { creationInstants.remove(subscriptionId); callbacks.remove(subscriptionId); String sitemapWithPageId = scopeOfSubscription.remove(subscriptionId); - if (sitemapWithPageId != null && !scopeOfSubscription.values().contains(sitemapWithPageId)) { + if (sitemapWithPageId != null && !scopeOfSubscription.containsValue(sitemapWithPageId)) { // this was the only subscription listening on this page, so we can dispose the listener ListenerRecord listener = pageChangeListeners.remove(sitemapWithPageId); if (listener != null) { diff --git a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/JerseyResponseBuilderUtils.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/JerseyResponseBuilderUtils.java index 01ba71b73c0..2c77487634f 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/JerseyResponseBuilderUtils.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/JerseyResponseBuilderUtils.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +25,8 @@ * Data transfer object until UIs are fixed. * *

        - * {@link https://github.com/openhab/openhab-core/issues/1216} + * + * @see Sitemap Events: registration response buggy * * @author Markus Rathgeb - Initial contribution */ diff --git a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/MappingDTO.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/MappingDTO.java index 585f2c5ce24..d7a91db619f 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/MappingDTO.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/MappingDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,12 @@ * * @author Kai Kreuzer - Initial contribution * @author Laurent Garnier - New fields position and icon + * @author Laurent Garnier - Replace field position by fields row and column */ public class MappingDTO { - public Integer position; + public Integer row; + public Integer column; public String command; public String label; public String icon; diff --git a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/PageDTO.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/PageDTO.java index c1581ca73a1..f1a6bc879d2 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/PageDTO.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/PageDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/ServerAliveEvent.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/ServerAliveEvent.java index f5890393d0a..1b6b4d90bb3 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/ServerAliveEvent.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/ServerAliveEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapChangedEvent.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapChangedEvent.java index b048f457582..e845f7de20e 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapChangedEvent.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapChangedEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapDTO.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapDTO.java index 727764f9798..dd11cd86478 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapDTO.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapEvent.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapEvent.java index 78702f55a96..b00c0bb48f4 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapEvent.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapResource.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapResource.java index 77827ff34de..adfa1f99580 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapResource.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -357,6 +357,8 @@ public Response getPageData(@Context HttpHeaders headers, @ApiResponse(responseCode = "201", description = "Subscription created."), @ApiResponse(responseCode = "503", description = "Subscriptions limit reached.") }) public Object createEventSubscription() { + logger.debug("Received HTTP POST request from IP {} at '{}'", request.getRemoteAddr(), uriInfo.getPath()); + String subscriptionId = subscriptions.createSubscription(this); if (subscriptionId == null) { return JSONResponse.createResponse(Status.SERVICE_UNAVAILABLE, null, @@ -397,9 +399,6 @@ public void getSitemapEvents(@Context final SseEventSink sseEventSink, @Context /** * Subscribes the connecting client to the stream of sitemap events. - * - * @return {@link EventOutput} object associated with the incoming - * connection. */ @GET @Path(SEGMENT_EVENTS + "/{subscriptionid: [a-zA-Z_0-9-]+}") @@ -413,6 +412,9 @@ public void getSitemapEvents(@Context final SseEventSink sseEventSink, @Context @QueryParam("sitemap") @Parameter(description = "sitemap name") @Nullable String sitemapname, @QueryParam("pageid") @Parameter(description = "page id") @Nullable String pageId) { getSitemapEvents(sseEventSink, response, subscriptionId, sitemapname, pageId, false); + logger.debug("Received HTTP GET request from IP {} at '{}' for sitemap {} and page {}", request.getRemoteAddr(), + uriInfo.getPath(), sitemapname, pageId); + } private void getSitemapEvents(SseEventSink sseEventSink, HttpServletResponse response, String subscriptionId, @@ -662,6 +664,7 @@ private PageDTO createPageBean(String sitemapName, @Nullable String title, @Null if (widget instanceof Slider sliderWidget) { bean.sendFrequency = sliderWidget.getFrequency(); bean.switchSupport = sliderWidget.isSwitchEnabled(); + bean.releaseOnly = sliderWidget.isReleaseOnly(); bean.minValue = sliderWidget.getMinValue(); bean.maxValue = sliderWidget.getMaxValue(); bean.step = sliderWidget.getStep(); @@ -705,10 +708,10 @@ private PageDTO createPageBean(String sitemapName, @Nullable String title, @Null bean.step = setpointWidget.getStep(); } if (widget instanceof Buttongrid buttonGridWidget) { - bean.columns = buttonGridWidget.getColumns(); for (Button button : buttonGridWidget.getButtons()) { MappingDTO mappingBean = new MappingDTO(); - mappingBean.position = button.getPosition(); + mappingBean.row = button.getRow(); + mappingBean.column = button.getColumn(); mappingBean.command = button.getCmd(); mappingBean.label = button.getLabel(); mappingBean.icon = button.getIcon(); diff --git a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapWidgetEvent.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapWidgetEvent.java index 9d5b07a738d..3cd39e68d24 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapWidgetEvent.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapWidgetEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SseSinkInfo.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SseSinkInfo.java index 53affdc11db..23886600585 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SseSinkInfo.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SseSinkInfo.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/WidgetDTO.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/WidgetDTO.java index ae475be9685..e454c484883 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/WidgetDTO.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/WidgetDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,6 +27,7 @@ * @author Mark herwege - New fields pattern, unit * @author Laurent Garnier - New field columns * @author Danny Baumann - New field labelSource + * @author Laurent Garnier - Remove field columns */ public class WidgetDTO { @@ -54,6 +55,7 @@ public class WidgetDTO { // widget-specific attributes public final List mappings = new ArrayList<>(); public Boolean switchSupport; + public Boolean releaseOnly; public Integer sendFrequency; public Integer refresh; public Integer height; @@ -68,7 +70,6 @@ public class WidgetDTO { public String yAxisDecimalPattern; public Boolean legend; public Boolean forceAsItem; - public Integer columns; public String state; public EnrichedItemDTO item; diff --git a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/WidgetsChangeListener.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/WidgetsChangeListener.java index 0f545c55b51..3e80d1d1474 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/WidgetsChangeListener.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/WidgetsChangeListener.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.sitemap/src/test/java/org/openhab/core/io/rest/sitemap/internal/SitemapResourceTest.java b/bundles/org.openhab.core.io.rest.sitemap/src/test/java/org/openhab/core/io/rest/sitemap/internal/SitemapResourceTest.java index 686fbf01707..1dd3f0988a4 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/test/java/org/openhab/core/io/rest/sitemap/internal/SitemapResourceTest.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/test/java/org/openhab/core/io/rest/sitemap/internal/SitemapResourceTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -515,7 +515,7 @@ private void configureSitemapProviderMock() { when(sitemapProviderMock.getSitemap(SITEMAP_MODEL_NAME)).thenReturn(defaultSitemapMock); } - private class TestItem extends GenericItem { + private static class TestItem extends GenericItem { public TestItem(String name) { super("Number", name); diff --git a/bundles/org.openhab.core.io.rest.sse/pom.xml b/bundles/org.openhab.core.io.rest.sse/pom.xml index 873873450dd..224868206bd 100644 --- a/bundles/org.openhab.core.io.rest.sse/pom.xml +++ b/bundles/org.openhab.core.io.rest.sse/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.rest.sse diff --git a/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/SseResource.java b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/SseResource.java index 9cbb7bd28cb..31f368ca524 100644 --- a/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/SseResource.java +++ b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/SseResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/SseItemStatesEventBuilder.java b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/SseItemStatesEventBuilder.java index 5af468ffbbb..840f675f0a4 100644 --- a/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/SseItemStatesEventBuilder.java +++ b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/SseItemStatesEventBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/SsePublisher.java b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/SsePublisher.java index 2969f6e0658..fbdda854c74 100644 --- a/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/SsePublisher.java +++ b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/SsePublisher.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/SseSinkItemInfo.java b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/SseSinkItemInfo.java index e799933a904..65e2b380bd5 100644 --- a/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/SseSinkItemInfo.java +++ b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/SseSinkItemInfo.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/SseSinkTopicInfo.java b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/SseSinkTopicInfo.java index 65cb783e838..02c47512d8a 100644 --- a/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/SseSinkTopicInfo.java +++ b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/SseSinkTopicInfo.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/dto/EventDTO.java b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/dto/EventDTO.java index d4288835f07..9173ee54200 100644 --- a/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/dto/EventDTO.java +++ b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/dto/EventDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/dto/StateDTO.java b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/dto/StateDTO.java index 0c908369f32..865bcdec5c0 100644 --- a/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/dto/StateDTO.java +++ b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/dto/StateDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/listeners/SseEventSubscriber.java b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/listeners/SseEventSubscriber.java index b8890cfa2c0..9a77198c049 100644 --- a/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/listeners/SseEventSubscriber.java +++ b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/listeners/SseEventSubscriber.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/util/SseUtil.java b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/util/SseUtil.java index 9dd6af379aa..461eefdfc62 100644 --- a/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/util/SseUtil.java +++ b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/openhab/core/io/rest/sse/internal/util/SseUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.sse/src/test/java/org/openhab/core/io/rest/sse/internal/util/SseUtilTest.java b/bundles/org.openhab.core.io.rest.sse/src/test/java/org/openhab/core/io/rest/sse/internal/util/SseUtilTest.java index 6cba1f1576e..16420502410 100644 --- a/bundles/org.openhab.core.io.rest.sse/src/test/java/org/openhab/core/io/rest/sse/internal/util/SseUtilTest.java +++ b/bundles/org.openhab.core.io.rest.sse/src/test/java/org/openhab/core/io/rest/sse/internal/util/SseUtilTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.swagger/pom.xml b/bundles/org.openhab.core.io.rest.swagger/pom.xml index 55eacced95c..7f44036b2f0 100644 --- a/bundles/org.openhab.core.io.rest.swagger/pom.xml +++ b/bundles/org.openhab.core.io.rest.swagger/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.rest.swagger diff --git a/bundles/org.openhab.core.io.rest.swagger/src/main/java/org/openhab/core/io/rest/swagger/impl/OpenApiResource.java b/bundles/org.openhab.core.io.rest.swagger/src/main/java/org/openhab/core/io/rest/swagger/impl/OpenApiResource.java index e7b41ade3f3..bb6cd38a6da 100644 --- a/bundles/org.openhab.core.io.rest.swagger/src/main/java/org/openhab/core/io/rest/swagger/impl/OpenApiResource.java +++ b/bundles/org.openhab.core.io.rest.swagger/src/main/java/org/openhab/core/io/rest/swagger/impl/OpenApiResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.transform/pom.xml b/bundles/org.openhab.core.io.rest.transform/pom.xml index 31514c845e8..0870c63eec1 100644 --- a/bundles/org.openhab.core.io.rest.transform/pom.xml +++ b/bundles/org.openhab.core.io.rest.transform/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.rest.transform diff --git a/bundles/org.openhab.core.io.rest.transform/src/main/java/org/openhab/core/io/rest/transform/TransformationDTO.java b/bundles/org.openhab.core.io.rest.transform/src/main/java/org/openhab/core/io/rest/transform/TransformationDTO.java index 81288d36b09..c26ba66cf57 100644 --- a/bundles/org.openhab.core.io.rest.transform/src/main/java/org/openhab/core/io/rest/transform/TransformationDTO.java +++ b/bundles/org.openhab.core.io.rest.transform/src/main/java/org/openhab/core/io/rest/transform/TransformationDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.transform/src/main/java/org/openhab/core/io/rest/transform/internal/TransformationResource.java b/bundles/org.openhab.core.io.rest.transform/src/main/java/org/openhab/core/io/rest/transform/internal/TransformationResource.java index 9e9942864ca..ad86c9948f6 100644 --- a/bundles/org.openhab.core.io.rest.transform/src/main/java/org/openhab/core/io/rest/transform/internal/TransformationResource.java +++ b/bundles/org.openhab.core.io.rest.transform/src/main/java/org/openhab/core/io/rest/transform/internal/TransformationResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.ui/pom.xml b/bundles/org.openhab.core.io.rest.ui/pom.xml index f98d1b7b97d..b34615686d1 100644 --- a/bundles/org.openhab.core.io.rest.ui/pom.xml +++ b/bundles/org.openhab.core.io.rest.ui/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.rest.ui diff --git a/bundles/org.openhab.core.io.rest.ui/src/main/java/org/openhab/core/io/rest/ui/TileDTO.java b/bundles/org.openhab.core.io.rest.ui/src/main/java/org/openhab/core/io/rest/ui/TileDTO.java index ca46fb60b3d..c3fbf107758 100644 --- a/bundles/org.openhab.core.io.rest.ui/src/main/java/org/openhab/core/io/rest/ui/TileDTO.java +++ b/bundles/org.openhab.core.io.rest.ui/src/main/java/org/openhab/core/io/rest/ui/TileDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.ui/src/main/java/org/openhab/core/io/rest/ui/internal/UIResource.java b/bundles/org.openhab.core.io.rest.ui/src/main/java/org/openhab/core/io/rest/ui/internal/UIResource.java index eb34f73ce11..e6fef43677f 100644 --- a/bundles/org.openhab.core.io.rest.ui/src/main/java/org/openhab/core/io/rest/ui/internal/UIResource.java +++ b/bundles/org.openhab.core.io.rest.ui/src/main/java/org/openhab/core/io/rest/ui/internal/UIResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -168,6 +168,7 @@ public Response getAllComponents(@Context Request request, @PathParam("namespace } CacheControl cc = new CacheControl(); + cc.setNoCache(true); cc.setMustRevalidate(true); cc.setPrivate(true); return Response.ok(new Stream2JSONInputStream(components)).lastModified(lastModifiedDate).cacheControl(cc) diff --git a/bundles/org.openhab.core.io.rest.voice/pom.xml b/bundles/org.openhab.core.io.rest.voice/pom.xml index f3983792953..136af284263 100644 --- a/bundles/org.openhab.core.io.rest.voice/pom.xml +++ b/bundles/org.openhab.core.io.rest.voice/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.rest.voice diff --git a/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/HLIMapper.java b/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/HLIMapper.java index 57c191f9c68..377902b22d9 100644 --- a/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/HLIMapper.java +++ b/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/HLIMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/HumanLanguageInterpreterDTO.java b/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/HumanLanguageInterpreterDTO.java index dfaa8752f14..292f99a416e 100644 --- a/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/HumanLanguageInterpreterDTO.java +++ b/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/HumanLanguageInterpreterDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/VoiceDTO.java b/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/VoiceDTO.java index 4788ec0686f..a42573877c9 100644 --- a/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/VoiceDTO.java +++ b/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/VoiceDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/VoiceMapper.java b/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/VoiceMapper.java index 63766b854b1..66764cb6175 100644 --- a/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/VoiceMapper.java +++ b/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/VoiceMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/VoiceResource.java b/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/VoiceResource.java index c0c84ebe96b..de11bac8b12 100644 --- a/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/VoiceResource.java +++ b/bundles/org.openhab.core.io.rest.voice/src/main/java/org/openhab/core/io/rest/voice/internal/VoiceResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest/pom.xml b/bundles/org.openhab.core.io.rest/pom.xml index 1775d4bb823..76c16538863 100644 --- a/bundles/org.openhab.core.io.rest/pom.xml +++ b/bundles/org.openhab.core.io.rest/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.rest diff --git a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/DTOMapper.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/DTOMapper.java index 7fb44b013f7..b876b6f5ce7 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/DTOMapper.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/DTOMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest/src/main/java/org/openhab/core/io/rest/JSONInputStream.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/JSONInputStream.java index 02958215afa..60e24d4d184 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/JSONInputStream.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/JSONInputStream.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest/src/main/java/org/openhab/core/io/rest/JSONResponse.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/JSONResponse.java index d0123394085..9032b2150d8 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/JSONResponse.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/JSONResponse.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest/src/main/java/org/openhab/core/io/rest/LocaleService.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/LocaleService.java index 5f84e8b0742..c7ba02edc14 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/LocaleService.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/LocaleService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest/src/main/java/org/openhab/core/io/rest/LocaleServiceImpl.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/LocaleServiceImpl.java index 385053eec81..48f31daece7 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/LocaleServiceImpl.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/LocaleServiceImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -62,12 +62,12 @@ public Locale getLocale(@Nullable String acceptLanguageHttpHeader) { @Reference(policy = ReferencePolicy.DYNAMIC) protected void setLocaleProvider(LocaleProvider provider) { - logger.debug("The localeProvider in LocaleUtilService has been set"); + logger.debug("The localeProvider in {} has been set", LocaleServiceImpl.class.getSimpleName()); localeProvider = provider; } protected void unsetLocaleProvider(LocaleProvider provider) { - logger.debug("The localeProvider in LocaleUtilService has been unset"); + logger.debug("The localeProvider in {} has been unset", LocaleServiceImpl.class.getSimpleName()); localeProvider = null; } diff --git a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/RESTConstants.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/RESTConstants.java index 7f3c5b5affb..5eae11761d4 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/RESTConstants.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/RESTConstants.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,15 @@ public class RESTConstants { public static final String JAX_RS_NAME = "openhab"; - public static final String API_VERSION = "5"; + /** + * Version of the openHAB API + * + * Version 1: initial version + * Version 2: include invisible widgets into sitemap response (#499) + * Version 3: Addition of anyFormat icon parameter (#978) + * Version 4: OH3, refactored extensions to addons (#1560) + * Version 5: transparent charts (#2502) + * Version 6: extended chart period parameter format (#3863) + */ + public static final String API_VERSION = "6"; } diff --git a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/RESTResource.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/RESTResource.java index 17bbdb283dd..c731d4132e8 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/RESTResource.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/RESTResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest/src/main/java/org/openhab/core/io/rest/SseBroadcaster.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/SseBroadcaster.java index 01e616e58ea..bc00d2fbca0 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/SseBroadcaster.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/SseBroadcaster.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest/src/main/java/org/openhab/core/io/rest/Stream2JSONInputStream.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/Stream2JSONInputStream.java index 734a17cbbae..510d13582aa 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/Stream2JSONInputStream.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/Stream2JSONInputStream.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest/src/main/java/org/openhab/core/io/rest/internal/Constants.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/Constants.java index 0ec2ed025af..ae099db56f6 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/Constants.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/Constants.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest/src/main/java/org/openhab/core/io/rest/internal/DTOMapperImpl.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/DTOMapperImpl.java index 4ce2559d543..38746219cfc 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/DTOMapperImpl.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/DTOMapperImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest/src/main/java/org/openhab/core/io/rest/internal/RESTApplicationImpl.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/RESTApplicationImpl.java index b6b53ebe686..043d8c2bdf0 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/RESTApplicationImpl.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/RESTApplicationImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest/src/main/java/org/openhab/core/io/rest/internal/filter/CorsFilter.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/filter/CorsFilter.java index 5d6bdf8d149..77149b8378b 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/filter/CorsFilter.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/filter/CorsFilter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.IOException; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.container.ContainerResponseContext; @@ -77,8 +76,7 @@ public class CorsFilter implements ContainerResponseFilter { static final List ACCEPTED_HTTP_METHODS_LIST = List.of(HTTP_GET_METHOD, HTTP_POST_METHOD, HTTP_PUT_METHOD, HTTP_DELETE_METHOD, HTTP_HEAD_METHOD, HTTP_OPTIONS_METHOD); - static final String ACCEPTED_HTTP_METHODS = ACCEPTED_HTTP_METHODS_LIST.stream() - .collect(Collectors.joining(HEADERS_SEPARATOR)); + static final String ACCEPTED_HTTP_METHODS = String.join(HEADERS_SEPARATOR, ACCEPTED_HTTP_METHODS_LIST); private final transient Logger logger = LoggerFactory.getLogger(CorsFilter.class); diff --git a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/filter/ProxyFilter.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/filter/ProxyFilter.java index 4159bb44c60..2284d840784 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/filter/ProxyFilter.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/filter/ProxyFilter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -94,7 +94,7 @@ public void filter(@NonNullByDefault({}) ContainerRequestContext ctx) throws IOE // it String uriString = scheme + "://" + host.trim(); - URI newBaseUri = null; + URI newBaseUri; try { newBaseUri = new URI(uriString); } catch (URISyntaxException e) { diff --git a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/RootResource.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/RootResource.java index b8e0277c006..b3d319bf3d3 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/RootResource.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/RootResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/SystemInfoResource.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/SystemInfoResource.java index de6cdce5935..a5db349e0f3 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/SystemInfoResource.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/SystemInfoResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -119,6 +119,7 @@ public Response getUoMInfo(final @Context Request request, final @Context UriInf } CacheControl cc = new CacheControl(); + cc.setNoCache(true); cc.setMustRevalidate(true); cc.setPrivate(true); diff --git a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/beans/RootBean.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/beans/RootBean.java index 9dac54cada9..2cf6e08da0f 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/beans/RootBean.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/beans/RootBean.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/beans/SystemInfoBean.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/beans/SystemInfoBean.java index 875551ec166..ef582c0ffc9 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/beans/SystemInfoBean.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/beans/SystemInfoBean.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/beans/UoMInfoBean.java b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/beans/UoMInfoBean.java index 225d19221d4..56ae1b47b05 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/beans/UoMInfoBean.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/openhab/core/io/rest/internal/resources/beans/UoMInfoBean.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest/src/test/java/org/openhab/core/io/rest/JSONResponseTest.java b/bundles/org.openhab.core.io.rest/src/test/java/org/openhab/core/io/rest/JSONResponseTest.java index b5d29da5958..329b2af8322 100644 --- a/bundles/org.openhab.core.io.rest/src/test/java/org/openhab/core/io/rest/JSONResponseTest.java +++ b/bundles/org.openhab.core.io.rest/src/test/java/org/openhab/core/io/rest/JSONResponseTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -131,7 +131,7 @@ public void shouldCreateSuccessResponseWithLargeStreamEntity() throws IOExceptio } @SuppressWarnings("unused") - private final class LargeEntity { + private static final class LargeEntity { private List randoms = getRandoms(); diff --git a/bundles/org.openhab.core.io.rest/src/test/java/org/openhab/core/io/rest/Stream2JSONInputStreamTest.java b/bundles/org.openhab.core.io.rest/src/test/java/org/openhab/core/io/rest/Stream2JSONInputStreamTest.java index 66366d57894..9a0559a662a 100644 --- a/bundles/org.openhab.core.io.rest/src/test/java/org/openhab/core/io/rest/Stream2JSONInputStreamTest.java +++ b/bundles/org.openhab.core.io.rest/src/test/java/org/openhab/core/io/rest/Stream2JSONInputStreamTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 @@ private String inputStreamToString(InputStream in) throws IOException { } @SuppressWarnings("unused") - private class DummyObject { + private static class DummyObject { private final String key; private final String value; diff --git a/bundles/org.openhab.core.io.rest/src/test/java/org/openhab/core/io/rest/internal/filter/CorsFilterTest.java b/bundles/org.openhab.core.io.rest/src/test/java/org/openhab/core/io/rest/internal/filter/CorsFilterTest.java index 5a25f914d12..8d58bdfa44e 100644 --- a/bundles/org.openhab.core.io.rest/src/test/java/org/openhab/core/io/rest/internal/filter/CorsFilterTest.java +++ b/bundles/org.openhab.core.io.rest/src/test/java/org/openhab/core/io/rest/internal/filter/CorsFilterTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.rest/src/test/java/org/openhab/core/io/rest/internal/filter/ProxyFilterTest.java b/bundles/org.openhab.core.io.rest/src/test/java/org/openhab/core/io/rest/internal/filter/ProxyFilterTest.java index 3c1be98069b..c1297de2307 100644 --- a/bundles/org.openhab.core.io.rest/src/test/java/org/openhab/core/io/rest/internal/filter/ProxyFilterTest.java +++ b/bundles/org.openhab.core.io.rest/src/test/java/org/openhab/core/io/rest/internal/filter/ProxyFilterTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mdns/pom.xml b/bundles/org.openhab.core.io.transport.mdns/pom.xml index 656b7179110..72ab9304639 100644 --- a/bundles/org.openhab.core.io.transport.mdns/pom.xml +++ b/bundles/org.openhab.core.io.transport.mdns/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.transport.mdns diff --git a/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/MDNSClient.java b/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/MDNSClient.java index 8ea31733ff2..f01073d5444 100644 --- a/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/MDNSClient.java +++ b/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/MDNSClient.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/MDNSService.java b/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/MDNSService.java index a87d46a79ff..fb858d56a6d 100644 --- a/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/MDNSService.java +++ b/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/MDNSService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/ServiceDescription.java b/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/ServiceDescription.java index 727230c99ab..7569a3a1852 100644 --- a/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/ServiceDescription.java +++ b/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/ServiceDescription.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/internal/MDNSActivator.java b/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/internal/MDNSActivator.java index 4d27f537f2e..2ce7f9396f2 100644 --- a/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/internal/MDNSActivator.java +++ b/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/internal/MDNSActivator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/internal/MDNSClientImpl.java b/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/internal/MDNSClientImpl.java index 2308c0ce1a3..7cd58d80d9b 100644 --- a/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/internal/MDNSClientImpl.java +++ b/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/internal/MDNSClientImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -191,6 +191,10 @@ private void registerServiceInternal(ServiceDescription description) throws IOEx @Override public void unregisterService(ServiceDescription description) { activeServices.remove(description); + unregisterServiceInternal(description); + } + + private void unregisterServiceInternal(ServiceDescription description) { for (JmDNS instance : jmdnsInstances.values()) { try { logger.debug("Unregistering service {} at {}:{} ({})", description.serviceType, @@ -277,7 +281,59 @@ private void createJmDNSByAddress(InetAddress address) { @Override public void onChanged(List added, List removed) { logger.debug("ip address change: added {}, removed {}", added, removed); - close(); - start(); + + Set filteredAddresses = getAllInetAddresses(); + + // First check if there is really a jmdns instance to remove or add + boolean changeRequired = false; + for (InetAddress address : jmdnsInstances.keySet()) { + if (!filteredAddresses.contains(address)) { + changeRequired = true; + break; + } + } + if (!changeRequired) { + for (InetAddress address : filteredAddresses) { + JmDNS jmdns = jmdnsInstances.get(address); + if (jmdns == null) { + changeRequired = true; + break; + } + } + } + if (!changeRequired) { + logger.debug("mDNS services already OK for these ip addresses"); + return; + } + + for (ServiceDescription description : activeServices) { + unregisterServiceInternal(description); + } + for (InetAddress address : jmdnsInstances.keySet()) { + if (!filteredAddresses.contains(address)) { + JmDNS jmdns = jmdnsInstances.remove(address); + if (jmdns != null) { + closeQuietly(jmdns); + logger.debug("mDNS service has been stopped ({} for IP {})", jmdns.getName(), + address.getHostAddress()); + } + } + } + for (InetAddress address : filteredAddresses) { + JmDNS jmdns = jmdnsInstances.get(address); + if (jmdns == null) { + createJmDNSByAddress(address); + } else { + logger.debug("mDNS service was already started ({} for IP {})", jmdns.getName(), + address.getHostAddress()); + } + } + for (ServiceDescription description : activeServices) { + try { + registerServiceInternal(description); + } catch (IOException e) { + logger.warn("Exception while registering service {}", description, e); + } + } } } diff --git a/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/internal/MDNSServiceImpl.java b/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/internal/MDNSServiceImpl.java index d420ae8c9b3..bb7195a2408 100644 --- a/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/internal/MDNSServiceImpl.java +++ b/bundles/org.openhab.core.io.transport.mdns/src/main/java/org/openhab/core/io/transport/mdns/internal/MDNSServiceImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/pom.xml b/bundles/org.openhab.core.io.transport.modbus/pom.xml index 2928f3fc1bb..e67bddb2424 100644 --- a/bundles/org.openhab.core.io.transport.modbus/pom.xml +++ b/bundles/org.openhab.core.io.transport.modbus/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.transport.modbus diff --git a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/AsyncModbusFailure.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/AsyncModbusFailure.java index bd96f849f6b..f1bcc4af9a5 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/AsyncModbusFailure.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/AsyncModbusFailure.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/AsyncModbusReadResult.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/AsyncModbusReadResult.java index 7b780e5c4e6..32fc250533b 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/AsyncModbusReadResult.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/AsyncModbusReadResult.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/AsyncModbusWriteResult.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/AsyncModbusWriteResult.java index 340e9246c0f..d8da4047ced 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/AsyncModbusWriteResult.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/AsyncModbusWriteResult.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/BitArray.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/BitArray.java index 370b4e122d9..b16591ae241 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/BitArray.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/BitArray.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -118,7 +118,7 @@ public String toString() { @Override public Iterator iterator() { - return IntStream.range(0, size()).mapToObj(i -> getBit(i)).iterator(); + return IntStream.range(0, size()).mapToObj(this::getBit).iterator(); } @Override diff --git a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusBitUtilities.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusBitUtilities.java index 92894fa36b8..17a90b6546f 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusBitUtilities.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusBitUtilities.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -278,9 +278,7 @@ public static short extractUInt8(byte[] bytes, int registerIndex, boolean hiByte public static short extractUInt8(byte[] bytes, int index) { assertIndexAndType(bytes, index, ValueType.UINT8); int signed = extractSInt8(bytes, index); - short unsigned = (short) (signed & 0xff); - assert unsigned >= 0; - return unsigned; + return (short) (signed & 0xff); } /** @@ -313,9 +311,7 @@ public static short extractSInt16(byte[] bytes, int index) { public static int extractUInt16(byte[] bytes, int index) { assertIndexAndType(bytes, index, ValueType.UINT16); int signed = extractSInt16(bytes, index); - int unsigned = signed & 0xffff; - assert unsigned >= 0; - return unsigned; + return signed & 0xffff; } /** @@ -350,9 +346,7 @@ public static int extractSInt32(byte[] bytes, int index) { public static long extractUInt32(byte[] bytes, int index) { assertIndexAndType(bytes, index, ValueType.UINT32); long signed = extractSInt32(bytes, index); - long unsigned = signed & 0xffff_ffffL; - assert unsigned >= 0; - return unsigned; + return signed & 0xffff_ffffL; } /** @@ -392,9 +386,7 @@ public static int extractSInt32Swap(byte[] bytes, int index) { public static long extractUInt32Swap(byte[] bytes, int index) { assertIndexAndType(bytes, index, ValueType.UINT32_SWAP); long signed = extractSInt32Swap(bytes, index); - long unsigned = signed & 0xffff_ffffL; - assert unsigned >= 0; - return unsigned; + return signed & 0xffff_ffffL; } /** @@ -651,7 +643,7 @@ public static ModbusRegisterArray commandToRegisters(Command command, ModbusCons // big endian byte ordering byte hi = (byte) (shortValue >> 8); byte lo = (byte) shortValue; - return new ModbusRegisterArray(new byte[] { hi, lo }); + return new ModbusRegisterArray(hi, lo); } case INT32: case UINT32: { @@ -661,7 +653,7 @@ public static ModbusRegisterArray commandToRegisters(Command command, ModbusCons byte lo1 = (byte) (intValue >> 16); byte hi2 = (byte) (intValue >> 8); byte lo2 = (byte) intValue; - return new ModbusRegisterArray(new byte[] { hi1, lo1, hi2, lo2 }); + return new ModbusRegisterArray(hi1, lo1, hi2, lo2); } case INT32_SWAP: case UINT32_SWAP: { @@ -672,7 +664,7 @@ public static ModbusRegisterArray commandToRegisters(Command command, ModbusCons byte hi2 = (byte) (intValue >> 8); byte lo2 = (byte) intValue; // Swapped order of registers - return new ModbusRegisterArray(new byte[] { hi2, lo2, hi1, lo1 }); + return new ModbusRegisterArray(hi2, lo2, hi1, lo1); } case FLOAT32: { float floatValue = numericCommand.floatValue(); @@ -682,7 +674,7 @@ public static ModbusRegisterArray commandToRegisters(Command command, ModbusCons byte lo1 = (byte) (intBits >> 16); byte hi2 = (byte) (intBits >> 8); byte lo2 = (byte) intBits; - return new ModbusRegisterArray(new byte[] { hi1, lo1, hi2, lo2 }); + return new ModbusRegisterArray(hi1, lo1, hi2, lo2); } case FLOAT32_SWAP: { float floatValue = numericCommand.floatValue(); @@ -693,7 +685,7 @@ public static ModbusRegisterArray commandToRegisters(Command command, ModbusCons byte hi2 = (byte) (intBits >> 8); byte lo2 = (byte) intBits; // Swapped order of registers - return new ModbusRegisterArray(new byte[] { hi2, lo2, hi1, lo1 }); + return new ModbusRegisterArray(hi2, lo2, hi1, lo1); } case INT64: case UINT64: { @@ -707,7 +699,7 @@ public static ModbusRegisterArray commandToRegisters(Command command, ModbusCons byte lo3 = (byte) (longValue >> 16); byte hi4 = (byte) (longValue >> 8); byte lo4 = (byte) longValue; - return new ModbusRegisterArray(new byte[] { hi1, lo1, hi2, lo2, hi3, lo3, hi4, lo4 }); + return new ModbusRegisterArray(hi1, lo1, hi2, lo2, hi3, lo3, hi4, lo4); } case INT64_SWAP: case UINT64_SWAP: { @@ -722,7 +714,7 @@ public static ModbusRegisterArray commandToRegisters(Command command, ModbusCons byte hi4 = (byte) (longValue >> 8); byte lo4 = (byte) longValue; // Swapped order of registers - return new ModbusRegisterArray(new byte[] { hi4, lo4, hi3, lo3, hi2, lo2, hi1, lo1 }); + return new ModbusRegisterArray(hi4, lo4, hi3, lo3, hi2, lo2, hi1, lo1); } default: throw new IllegalArgumentException( diff --git a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusCommunicationInterface.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusCommunicationInterface.java index 9fa775c47b9..400821c1b95 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusCommunicationInterface.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusCommunicationInterface.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusConstants.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusConstants.java index fa7fc83e88c..5b8f03957bb 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusConstants.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusConstants.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -55,7 +55,7 @@ public class ModbusConstants { * @author Sami Salonen - Initial contribution * */ - public static enum ValueType { + public enum ValueType { BIT("bit", 1), INT8("int8", 8), UINT8("uint8", 8), diff --git a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusFailureCallback.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusFailureCallback.java index b5531c34817..febd11d189e 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusFailureCallback.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusFailureCallback.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusManager.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusManager.java index e8d23f26a6b..7139efdc916 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusManager.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusManager.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusReadCallback.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusReadCallback.java index 7ae9c329cc8..a0a38c353e7 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusReadCallback.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusReadCallback.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusReadFunctionCode.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusReadFunctionCode.java index 36832060400..bfd80dea623 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusReadFunctionCode.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusReadFunctionCode.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusReadRequestBlueprint.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusReadRequestBlueprint.java index 8587ab122a8..9c4388f2e39 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusReadRequestBlueprint.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusReadRequestBlueprint.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusRegisterArray.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusRegisterArray.java index 6e1a840b5cb..1039194cb8a 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusRegisterArray.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusRegisterArray.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusResponse.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusResponse.java index 9d59a7cbc57..edb38835ac5 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusResponse.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusResponse.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusResultCallback.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusResultCallback.java index 214aa13e740..34d06d24a61 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusResultCallback.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusResultCallback.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteCallback.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteCallback.java index a23b7521837..0f1ec62664a 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteCallback.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteCallback.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteCoilRequestBlueprint.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteCoilRequestBlueprint.java index 8753294db14..794bba650f7 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteCoilRequestBlueprint.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteCoilRequestBlueprint.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteFunctionCode.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteFunctionCode.java index 5533ba2e0c4..12a2811e967 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteFunctionCode.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteFunctionCode.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteRegisterRequestBlueprint.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteRegisterRequestBlueprint.java index 895ea0679e0..2b97b902a66 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteRegisterRequestBlueprint.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteRegisterRequestBlueprint.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteRequestBlueprint.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteRequestBlueprint.java index 5528d77ee50..5475ba76af4 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteRequestBlueprint.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteRequestBlueprint.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteRequestBlueprintVisitor.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteRequestBlueprintVisitor.java index 4f66ae34a93..6a2dbb9ab77 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteRequestBlueprintVisitor.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ModbusWriteRequestBlueprintVisitor.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/PollTask.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/PollTask.java index 4c962bda9ca..bf9058977cf 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/PollTask.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/PollTask.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/TaskWithEndpoint.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/TaskWithEndpoint.java index e13ab408adb..244d75666f8 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/TaskWithEndpoint.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/TaskWithEndpoint.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ValueBuffer.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ValueBuffer.java index fdbe674dbb0..4a1af6c0317 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ValueBuffer.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/ValueBuffer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -108,7 +108,7 @@ public ValueBuffer mark() { * @throws InvalidMarkException If the mark has not been set */ public ValueBuffer reset() throws InvalidMarkException { - int mark = Optional.ofNullable(this.mark.get()).map(i -> i.get()).orElse(-1); + int mark = Optional.ofNullable(this.mark.get()).map(AtomicInteger::get).orElse(-1); if (mark < 0) { throw new InvalidMarkException(); } diff --git a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/WriteTask.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/WriteTask.java index fc5a2560660..9f2e6e48e0b 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/WriteTask.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/WriteTask.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/EndpointPoolConfiguration.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/EndpointPoolConfiguration.java index 5b694d00ebf..184bacbe251 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/EndpointPoolConfiguration.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/EndpointPoolConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusIPSlaveEndpoint.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusIPSlaveEndpoint.java index b0b08cec444..c8ce76bedad 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusIPSlaveEndpoint.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusIPSlaveEndpoint.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusSerialSlaveEndpoint.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusSerialSlaveEndpoint.java index 8ff2936b469..e609eef1cfd 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusSerialSlaveEndpoint.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusSerialSlaveEndpoint.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusSlaveEndpoint.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusSlaveEndpoint.java index fda03c56b08..15a8f3197ad 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusSlaveEndpoint.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusSlaveEndpoint.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusSlaveEndpointVisitor.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusSlaveEndpointVisitor.java index 8fa784553e9..a61938a5fee 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusSlaveEndpointVisitor.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusSlaveEndpointVisitor.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusTCPSlaveEndpoint.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusTCPSlaveEndpoint.java index 4f798d4b227..4800af25f4e 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusTCPSlaveEndpoint.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusTCPSlaveEndpoint.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusUDPSlaveEndpoint.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusUDPSlaveEndpoint.java index 6223d0f2e0b..d2db3e9ed33 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusUDPSlaveEndpoint.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/endpoint/ModbusUDPSlaveEndpoint.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusConnectionException.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusConnectionException.java index 4914de8f87e..46055d5967a 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusConnectionException.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusConnectionException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusSlaveErrorResponseException.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusSlaveErrorResponseException.java index 26f45a8b607..2e8cea90e76 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusSlaveErrorResponseException.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusSlaveErrorResponseException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -41,7 +41,7 @@ public abstract class ModbusSlaveErrorResponseException extends ModbusTransportE * @author Sami Salonen - Initial contribution * */ - public static enum KnownExceptionCode { + public enum KnownExceptionCode { ILLEGAL_FUNCTION(1), ILLEGAL_DATA_ACCESS(2), ILLEGAL_DATA_VALUE(3), @@ -55,7 +55,7 @@ public static enum KnownExceptionCode { private final int exceptionCode; - private KnownExceptionCode(int exceptionCode) { + KnownExceptionCode(int exceptionCode) { this.exceptionCode = exceptionCode; } diff --git a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusSlaveIOException.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusSlaveIOException.java index 568b072a2c1..8c66c3829ea 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusSlaveIOException.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusSlaveIOException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusTransportException.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusTransportException.java index 2edc6d39354..58067a43a66 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusTransportException.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusTransportException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusUnexpectedResponseFunctionCodeException.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusUnexpectedResponseFunctionCodeException.java index 83924e2d16f..32b46046388 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusUnexpectedResponseFunctionCodeException.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusUnexpectedResponseFunctionCodeException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusUnexpectedResponseSizeException.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusUnexpectedResponseSizeException.java index 20e91a99830..b65b1f9c446 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusUnexpectedResponseSizeException.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusUnexpectedResponseSizeException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusUnexpectedTransactionIdException.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusUnexpectedTransactionIdException.java index 9ecb9a504d9..8a47cb6d613 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusUnexpectedTransactionIdException.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusUnexpectedTransactionIdException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/AggregateStopWatch.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/AggregateStopWatch.java index e6516d17e08..28f6a781336 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/AggregateStopWatch.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/AggregateStopWatch.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/BasicPollTask.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/BasicPollTask.java index afec732a1ca..15ff8a6f72d 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/BasicPollTask.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/BasicPollTask.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/BasicWriteTask.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/BasicWriteTask.java index 97a63e3512c..52b774776fc 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/BasicWriteTask.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/BasicWriteTask.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusConnectionPool.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusConnectionPool.java index 8f4e8373210..01ea3e75762 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusConnectionPool.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusConnectionPool.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusLibraryWrapper.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusLibraryWrapper.java index b8a15504266..fce5ff57f02 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusLibraryWrapper.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusLibraryWrapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -190,7 +190,7 @@ public void visit(ModbusWriteCoilRequestBlueprint blueprint) { */ public static ModbusTransaction createTransactionForEndpoint(ModbusSlaveEndpoint endpoint, ModbusSlaveConnection connection) { - ModbusTransaction transaction = endpoint.accept(new ModbusSlaveEndpointVisitor() { + ModbusTransaction transaction = endpoint.accept(new ModbusSlaveEndpointVisitor<>() { @Override public @NonNull ModbusTransaction visit(ModbusTCPSlaveEndpoint modbusIPSlavePoolingKey) { @@ -264,7 +264,7 @@ public static BitVector convertBits(BitArray bits) { /** * Convert {@link ModbusRegisterArray} to array of {@link Register} * - * @param bits + * @param arr * @return */ public static Register[] convertRegisters(ModbusRegisterArray arr) { @@ -303,7 +303,7 @@ public static int getNumberOfItemsInResponse(ModbusResponse response, ModbusRead /** * Invoke callback with the data received * - * @param message original request + * @param request original request * @param callback callback for read * @param response Modbus library response object */ diff --git a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusManagerImpl.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusManagerImpl.java index 8c75042aaee..cbc23f48a45 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusManagerImpl.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusManagerImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -117,7 +117,7 @@ private interface ModbusOperation { * (ill-behaving slave) * @throws ModbusUnexpectedResponseSizeException when data length of the response and request do not match */ - public void accept(AggregateStopWatch timer, T task, ModbusSlaveConnection connection) + void accept(AggregateStopWatch timer, T task, ModbusSlaveConnection connection) throws ModbusException, IIOException, ModbusUnexpectedTransactionIdException, ModbusUnexpectedResponseFunctionCodeException, ModbusUnexpectedResponseSizeException; } @@ -205,7 +205,7 @@ public void accept(AggregateStopWatch timer, PollTask task, ModbusSlaveConnectio request.getFunctionCode(), libRequest.getHexMessage(), operationId); // Might throw ModbusIOException (I/O error) or ModbusSlaveException (explicit exception response from // slave) - timer.transaction.timeRunnableWithModbusException(() -> transaction.execute()); + timer.transaction.timeRunnableWithModbusException(transaction::execute); ModbusResponse response = transaction.getResponse(); logger.trace("Response for read request (FC={}, transaction ID={}): {} [operation ID {}]", response.getFunctionCode(), response.getTransactionID(), response.getHexMessage(), operationId); @@ -243,7 +243,7 @@ public void accept(AggregateStopWatch timer, WriteTask task, ModbusSlaveConnecti // Might throw ModbusIOException (I/O error) or ModbusSlaveException (explicit exception response from // slave) - timer.transaction.timeRunnableWithModbusException(() -> transaction.execute()); + timer.transaction.timeRunnableWithModbusException(transaction::execute); ModbusResponse response = transaction.getResponse(); logger.trace("Response for write request (FC={}, transaction ID={}): {} [operation ID {}]", response.getFunctionCode(), response.getTransactionID(), response.getHexMessage(), operationId); @@ -444,7 +444,7 @@ private void returnConnection(ModbusSlaveEndpoint endpoint, Optional void invokeCallbackWithError(R request, ModbusFailureCallback cal try { logger.trace("Calling error response callback {} for request {}. Error was {} {}", callback, request, error.getClass().getName(), error.getMessage()); - callback.handle(new AsyncModbusFailure(request, error)); + callback.handle(new AsyncModbusFailure<>(request, error)); } finally { logger.trace("Called write response callback {} for request {}. Error was {} {}", callback, request, error.getClass().getName(), error.getMessage()); @@ -575,7 +575,7 @@ private , } int tryIndex = 0; - /** + /* * last execution is tracked such that the endpoint is not spammed on retry. First retry can be executed * right away since getConnection ensures enough time has passed since last transaction. More precisely, * ModbusSlaveConnectionFactoryImpl sleeps on activate() (i.e. before returning connection). @@ -934,7 +934,7 @@ private void unregisterCommunicationInterface(ModbusCommunicationInterface commI private void maybeCloseConnections(ModbusSlaveEndpoint endpoint) { boolean lastCommWithThisEndpointWasRemoved = communicationInterfaces.stream() - .filter(comm -> comm.endpoint.equals(endpoint)).count() == 0L; + .noneMatch(comm -> comm.endpoint.equals(endpoint)); if (lastCommWithThisEndpointWasRemoved) { // Since last communication interface pointing to this endpoint was closed, we can clean up resources // and disconnect connections. diff --git a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusPoolConfig.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusPoolConfig.java index 8707e30191d..a6bae131ff3 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusPoolConfig.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusPoolConfig.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusResponseImpl.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusResponseImpl.java index bbbb6b25b0e..bb9a1f93800 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusResponseImpl.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusResponseImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusSlaveErrorResponseExceptionImpl.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusSlaveErrorResponseExceptionImpl.java index 6e4b22cf2be..c4ecd9f4553 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusSlaveErrorResponseExceptionImpl.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusSlaveErrorResponseExceptionImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +50,7 @@ public int getExceptionCode() { @Override public @Nullable String getMessage() { return String.format("Slave responded with error=%d (%s)", rawCode, - exceptionCode.map(c -> c.name()).orElse("unknown error code")); + exceptionCode.map(Enum::name).orElse("unknown error code")); } @Override diff --git a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusSlaveIOExceptionImpl.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusSlaveIOExceptionImpl.java index b1e9a8c7e08..2115a540a59 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusSlaveIOExceptionImpl.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/ModbusSlaveIOExceptionImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/SimpleStopWatch.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/SimpleStopWatch.java index dce26d03dec..a7ed2030b56 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/SimpleStopWatch.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/SimpleStopWatch.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,13 +33,13 @@ public class SimpleStopWatch { private volatile long resumed; @FunctionalInterface - public abstract interface SupplierWithPollTaskUnregisteredException { - public abstract T get() throws ModbusManagerImpl.PollTaskUnregistered; + public interface SupplierWithPollTaskUnregisteredException { + T get() throws ModbusManagerImpl.PollTaskUnregistered; } @FunctionalInterface - public abstract interface RunnableWithModbusException { - public abstract void run() throws ModbusException; + public interface RunnableWithModbusException { + void run() throws ModbusException; } /** @@ -143,7 +143,7 @@ public void timeRunnableWithModbusException(RunnableWithModbusException action) * * First StopWatch is resumed, then action is applied. Finally the StopWatch is suspended. * - * @param supplier action to time + * @param runnable action to time * @return return value from supplier */ public void timeRunnable(Runnable runnable) { diff --git a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/pooling/ModbusSlaveConnectionEvictionPolicy.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/pooling/ModbusSlaveConnectionEvictionPolicy.java index 4103105b531..2e4d32e5f04 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/pooling/ModbusSlaveConnectionEvictionPolicy.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/pooling/ModbusSlaveConnectionEvictionPolicy.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/pooling/ModbusSlaveConnectionFactory.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/pooling/ModbusSlaveConnectionFactory.java index 0ee58d4c6d9..4ebe4bdb9b6 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/pooling/ModbusSlaveConnectionFactory.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/pooling/ModbusSlaveConnectionFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/pooling/ModbusSlaveConnectionFactoryImpl.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/pooling/ModbusSlaveConnectionFactoryImpl.java index 2ffca70177d..52836cc54ee 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/pooling/ModbusSlaveConnectionFactoryImpl.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/internal/pooling/ModbusSlaveConnectionFactoryImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -105,8 +105,8 @@ public boolean maybeResetConnection(String activityName) { long reconnectAfterMillis = configuration.getReconnectAfterMillis(); long connectionAgeMillis = System.currentTimeMillis() - localLastConnected; long disconnectIfConnectedBeforeMillis = disconnectIfConnectedBefore.getOrDefault(localEndpoint, -1L); - boolean disconnectSinceTooOldConnection = disconnectIfConnectedBeforeMillis < 0L ? false - : localLastConnected <= disconnectIfConnectedBeforeMillis; + boolean disconnectSinceTooOldConnection = disconnectIfConnectedBeforeMillis >= 0L + && localLastConnected <= disconnectIfConnectedBeforeMillis; boolean shouldBeDisconnected = (reconnectAfterMillis == 0 || (reconnectAfterMillis > 0 && connectionAgeMillis > reconnectAfterMillis) || disconnectSinceTooOldConnection); diff --git a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/json/WriteRequestJsonUtilities.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/json/WriteRequestJsonUtilities.java index 3f8ae22bb2d..a0acce3143f 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/json/WriteRequestJsonUtilities.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/json/WriteRequestJsonUtilities.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -92,7 +92,7 @@ private WriteRequestJsonUtilities() { */ public static Collection fromJson(int unitId, String jsonString) { JsonArray jsonArray = JsonParser.parseString(jsonString).getAsJsonArray(); - if (jsonArray.size() == 0) { + if (jsonArray.isEmpty()) { return new LinkedList<>(); } Deque writes = new LinkedList<>(); @@ -169,11 +169,11 @@ private static ModbusWriteRequestBlueprint constructBluerint(int unitId, @Nullab writeSingle.set(true); if (valuesElem.size() != 1) { throw new IllegalArgumentException(String - .format("Expecting single value with functionCode=%s, got: %d", functionCode, valuesElem)); + .format("Expecting single value with functionCode=%s, got: %s", functionCode, valuesElem)); } // fall-through to WRITE_MULTIPLE_COILS case WRITE_MULTIPLE_COILS: - if (valuesElem.size() == 0) { + if (valuesElem.isEmpty()) { throw new IllegalArgumentException("Must provide at least one coil"); } else if (valuesElem.size() > ModbusConstants.MAX_BITS_WRITE_COUNT) { throw new IllegalArgumentException( @@ -189,7 +189,7 @@ private static ModbusWriteRequestBlueprint constructBluerint(int unitId, @Nullab writeSingle.set(true); if (valuesElem.size() != 1) { throw new IllegalArgumentException(String - .format("Expecting single value with functionCode=%s, got: %d", functionCode, valuesElem)); + .format("Expecting single value with functionCode=%s, got: %s", functionCode, valuesElem)); } // fall-through to WRITE_MULTIPLE_REGISTERS case WRITE_MULTIPLE_REGISTERS: { diff --git a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/AbstractRequestComparer.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/AbstractRequestComparer.java index 3aeb477c916..72ff3a0af02 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/AbstractRequestComparer.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/AbstractRequestComparer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 @@ abstract class AbstractRequestComparer ex private ModbusWriteFunctionCode expectedFunctionCode; private int expectedMaxTries; - public AbstractRequestComparer(int expectedUnitId, int expectedAddress, + protected AbstractRequestComparer(int expectedUnitId, int expectedAddress, ModbusWriteFunctionCode expectedFunctionCode, int expectedMaxTries) { this.expectedUnitId = expectedUnitId; this.expectedAddress = expectedAddress; diff --git a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BasicBitArrayTest.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BasicBitArrayTest.java index 82d3592b9cd..ae3bd72a629 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BasicBitArrayTest.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BasicBitArrayTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesCommandToRegistersTest.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesCommandToRegistersTest.java index 5e94246de9d..cdad96144ad 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesCommandToRegistersTest.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesCommandToRegistersTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractBitTest.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractBitTest.java index 9f8bb515c93..cd7e058df64 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractBitTest.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractBitTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractFloat32Test.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractFloat32Test.java index c9d595fc402..6579bf7fb25 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractFloat32Test.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractFloat32Test.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractIndividualMethodsTest.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractIndividualMethodsTest.java index e191fbbbf1b..d530cf723a5 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractIndividualMethodsTest.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractIndividualMethodsTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 @@ private static Stream registerVariations(Object expectedResult, ValueT for (int offset = 0; offset < 5; offset++) { int byteIndex = origByteIndex + offset; byte[] bytesOffsetted = new byte[origBytes.length + offset]; - for (int i = 0; i < bytesOffsetted.length; i++) { - bytesOffsetted[i] = 99; - } + Arrays.fill(bytesOffsetted, (byte) 99); System.arraycopy(origBytes, 0, bytesOffsetted, offset, origBytes.length); // offsetted: streamBuilder.add(new Object[] { expectedResult, type, bytesOffsetted, byteIndex }); @@ -105,7 +103,7 @@ private void testIndividual(Object expectedResult, ValueType type, byte[] bytes, type); final Object expectedNumber; if (expectedResult instanceof Class class1 && Exception.class.isAssignableFrom(class1)) { - assertThrows((Class) expectedResult, () -> methodUnderTest.get()); + assertThrows((Class) expectedResult, methodUnderTest::get); } else if (expectedResult instanceof Optional optional) { assertTrue(optional.isEmpty()); if (defaultWhenEmptyOptional == null) { @@ -128,7 +126,7 @@ public static Stream filteredTestDataSInt16() { public void testExtractIndividualSInt16(Object expectedResult, ValueType type, byte[] bytes, int byteIndex) throws InstantiationException, IllegalAccessException { testIndividual(expectedResult, type, bytes, byteIndex, () -> ModbusBitUtilities.extractSInt16(bytes, byteIndex), - decimal -> decimal.shortValue()); + Number::shortValue); } public static Stream filteredTestDataUInt16() { @@ -140,7 +138,7 @@ public static Stream filteredTestDataUInt16() { public void testExtractIndividualUInt16(Object expectedResult, ValueType type, byte[] bytes, int byteIndex) throws InstantiationException, IllegalAccessException { testIndividual(expectedResult, type, bytes, byteIndex, () -> ModbusBitUtilities.extractUInt16(bytes, byteIndex), - decimal -> decimal.intValue()); + DecimalType::intValue); } public static Stream filteredTestDataSInt32() { @@ -152,7 +150,7 @@ public static Stream filteredTestDataSInt32() { public void testExtractIndividualSInt32(Object expectedResult, ValueType type, byte[] bytes, int byteIndex) throws InstantiationException, IllegalAccessException { testIndividual(expectedResult, type, bytes, byteIndex, () -> ModbusBitUtilities.extractSInt32(bytes, byteIndex), - decimal -> decimal.intValue()); + DecimalType::intValue); } public static Stream filteredTestDataUInt32() { @@ -164,7 +162,7 @@ public static Stream filteredTestDataUInt32() { public void testExtractIndividualUInt32(Object expectedResult, ValueType type, byte[] bytes, int byteIndex) throws InstantiationException, IllegalAccessException { testIndividual(expectedResult, type, bytes, byteIndex, () -> ModbusBitUtilities.extractUInt32(bytes, byteIndex), - decimal -> decimal.longValue()); + DecimalType::longValue); } public static Stream filteredTestDataSInt32Swap() { @@ -176,7 +174,7 @@ public static Stream filteredTestDataSInt32Swap() { public void testExtractIndividualSInt32Swap(Object expectedResult, ValueType type, byte[] bytes, int byteIndex) throws InstantiationException, IllegalAccessException { testIndividual(expectedResult, type, bytes, byteIndex, - () -> ModbusBitUtilities.extractSInt32Swap(bytes, byteIndex), decimal -> decimal.intValue()); + () -> ModbusBitUtilities.extractSInt32Swap(bytes, byteIndex), DecimalType::intValue); } public static Stream filteredTestDataUInt32Swap() { @@ -188,7 +186,7 @@ public static Stream filteredTestDataUInt32Swap() { public void testExtractIndividualUInt32Swap(Object expectedResult, ValueType type, byte[] bytes, int byteIndex) throws InstantiationException, IllegalAccessException { testIndividual(expectedResult, type, bytes, byteIndex, - () -> ModbusBitUtilities.extractUInt32Swap(bytes, byteIndex), decimal -> decimal.longValue()); + () -> ModbusBitUtilities.extractUInt32Swap(bytes, byteIndex), DecimalType::longValue); } public static Stream filteredTestDataSInt64() { @@ -200,7 +198,7 @@ public static Stream filteredTestDataSInt64() { public void testExtractIndividualSInt64(Object expectedResult, ValueType type, byte[] bytes, int byteIndex) throws InstantiationException, IllegalAccessException { testIndividual(expectedResult, type, bytes, byteIndex, () -> ModbusBitUtilities.extractSInt64(bytes, byteIndex), - decimal -> decimal.longValue()); + DecimalType::longValue); } public static Stream filteredTestDataUInt64() { @@ -224,7 +222,7 @@ public static Stream filteredTestDataSInt64Swap() { public void testExtractIndividualSInt64Swap(Object expectedResult, ValueType type, byte[] bytes, int byteIndex) throws InstantiationException, IllegalAccessException { testIndividual(expectedResult, type, bytes, byteIndex, - () -> ModbusBitUtilities.extractSInt64Swap(bytes, byteIndex), decimal -> decimal.longValue()); + () -> ModbusBitUtilities.extractSInt64Swap(bytes, byteIndex), DecimalType::longValue); } public static Stream filteredTestDataUInt64Swap() { @@ -249,7 +247,7 @@ public static Stream filteredTestDataFloat32() { public void testExtractIndividualFloat32(Object expectedResult, ValueType type, byte[] bytes, int byteIndex) throws InstantiationException, IllegalAccessException { testIndividual(expectedResult, type, bytes, byteIndex, - () -> ModbusBitUtilities.extractFloat32(bytes, byteIndex), decimal -> decimal.floatValue(), Float.NaN); + () -> ModbusBitUtilities.extractFloat32(bytes, byteIndex), DecimalType::floatValue, Float.NaN); } public static Stream filteredTestDataFloat32Swap() { @@ -261,7 +259,6 @@ public static Stream filteredTestDataFloat32Swap() { public void testExtractIndividualFloat32Swap(Object expectedResult, ValueType type, byte[] bytes, int byteIndex) throws InstantiationException, IllegalAccessException { testIndividual(expectedResult, type, bytes, byteIndex, - () -> ModbusBitUtilities.extractFloat32Swap(bytes, byteIndex), decimal -> decimal.floatValue(), - Float.NaN); + () -> ModbusBitUtilities.extractFloat32Swap(bytes, byteIndex), DecimalType::floatValue, Float.NaN); } } diff --git a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractInt8Test.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractInt8Test.java index 1848545268a..3e98dfa721c 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractInt8Test.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractInt8Test.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractStateFromRegistersTest.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractStateFromRegistersTest.java index 2343f811cae..8eef9d08067 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractStateFromRegistersTest.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractStateFromRegistersTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractStringTest.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractStringTest.java index 33a95fb3e57..faca19b7ed0 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractStringTest.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesExtractStringTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesTranslateCommand2BooleanTest.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesTranslateCommand2BooleanTest.java index 5e3f393230e..f83c58b5a0b 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesTranslateCommand2BooleanTest.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/BitUtilitiesTranslateCommand2BooleanTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/CoilMatcher.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/CoilMatcher.java index 3d8abf66d74..644c4f2dc29 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/CoilMatcher.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/CoilMatcher.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/IntegrationTestSupport.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/IntegrationTestSupport.java index 0ec22cf398d..00eeca41ce3 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/IntegrationTestSupport.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/IntegrationTestSupport.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -278,7 +278,7 @@ private void startSerialServer() { } public ModbusSlaveEndpoint getEndpoint() { - assert tcpModbusPort > 0; + assertTrue(tcpModbusPort > 0); return new ModbusTCPSlaveEndpoint("127.0.0.1", tcpModbusPort, false); } diff --git a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/ModbusSlaveEndpointTestCase.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/ModbusSlaveEndpointTestCase.java index cd3e3a47c48..b4f1256b064 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/ModbusSlaveEndpointTestCase.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/ModbusSlaveEndpointTestCase.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/ModbusSlaveErrorResponseExceptionImplTest.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/ModbusSlaveErrorResponseExceptionImplTest.java index f60b11ac8d8..12ad73ae502 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/ModbusSlaveErrorResponseExceptionImplTest.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/ModbusSlaveErrorResponseExceptionImplTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/RegisterMatcher.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/RegisterMatcher.java index 014c3fd2237..381b0b24d10 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/RegisterMatcher.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/RegisterMatcher.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/ResultCaptor.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/ResultCaptor.java index 1002d252048..42d55bd2f7e 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/ResultCaptor.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/ResultCaptor.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/SmokeTest.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/SmokeTest.java index 78b52e8b29f..126dee5c63e 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/SmokeTest.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/SmokeTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 @@ public void testSlaveReadErrorResponse() throws Exception { try (ModbusCommunicationInterface comms = modbusManager.newModbusCommunicationInterface(endpoint, null)) { comms.submitOneTimePoll(new ModbusReadRequestBlueprint(SLAVE_UNIT_ID, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS, 0, 5, 1), result -> { - assert result.getRegisters().isPresent(); + assertTrue(result.getRegisters().isPresent()); okCount.incrementAndGet(); callbackCalled.countDown(); }, failure -> { @@ -169,7 +169,7 @@ public void testSlaveReadErrorResponse() throws Exception { assertThat(okCount.get(), is(equalTo(0))); assertThat(errorCount.get(), is(equalTo(1))); - assertTrue(lastError.get() instanceof ModbusSlaveErrorResponseException, lastError.toString()); + assertInstanceOf(ModbusSlaveErrorResponseException.class, lastError.get(), lastError.toString()); } } @@ -194,7 +194,7 @@ public void testSlaveConnectionError() throws Exception { configuration)) { comms.submitOneTimePoll(new ModbusReadRequestBlueprint(SLAVE_UNIT_ID, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS, 0, 5, 1), result -> { - assert result.getRegisters().isPresent(); + assertTrue(result.getRegisters().isPresent()); okCount.incrementAndGet(); callbackCalled.countDown(); }, failure -> { @@ -206,7 +206,7 @@ public void testSlaveConnectionError() throws Exception { assertThat(okCount.get(), is(equalTo(0))); assertThat(errorCount.get(), is(equalTo(1))); - assertTrue(lastError.get() instanceof ModbusConnectionException, lastError.toString()); + assertInstanceOf(ModbusConnectionException.class, lastError.get(), lastError.toString()); } } @@ -228,7 +228,7 @@ public void testIOError() throws Exception { try (ModbusCommunicationInterface comms = modbusManager.newModbusCommunicationInterface(endpoint, null)) { comms.submitOneTimePoll(new ModbusReadRequestBlueprint(SLAVE_UNIT_ID, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS, 0, 5, 1), result -> { - assert result.getRegisters().isPresent(); + assertTrue(result.getRegisters().isPresent()); okCount.incrementAndGet(); callbackCalled.countDown(); }, failure -> { @@ -239,7 +239,7 @@ public void testIOError() throws Exception { assertTrue(callbackCalled.await(15, TimeUnit.SECONDS)); assertThat(okCount.get(), is(equalTo(0))); assertThat(lastError.toString(), errorCount.get(), is(equalTo(1))); - assertTrue(lastError.get() instanceof ModbusSlaveIOException, lastError.toString()); + assertInstanceOf(ModbusSlaveIOException.class, lastError.get(), lastError.toString()); } } @@ -478,7 +478,7 @@ public void testOneOffWriteMultipleCoilError() throws Exception { assertTrue(callbackCalled.await(60, TimeUnit.SECONDS)); assertThat(unexpectedCount.get(), is(equalTo(0))); - assertTrue(lastError.get() instanceof ModbusSlaveErrorResponseException, lastError.toString()); + assertInstanceOf(ModbusSlaveErrorResponseException.class, lastError.get(), lastError.toString()); assertThat(modbustRequestCaptor.getAllReturnValues().size(), is(equalTo(1))); ModbusRequest request = modbustRequestCaptor.getAllReturnValues().get(0); @@ -555,7 +555,7 @@ public void testOneOffWriteSingleCoilError() throws Exception { assertTrue(callbackCalled.await(60, TimeUnit.SECONDS)); assertThat(unexpectedCount.get(), is(equalTo(0))); - assertTrue(lastError.get() instanceof ModbusSlaveErrorResponseException, lastError.toString()); + assertInstanceOf(ModbusSlaveErrorResponseException.class, lastError.get(), lastError.toString()); assertThat(modbustRequestCaptor.getAllReturnValues().size(), is(equalTo(1))); ModbusRequest request = modbustRequestCaptor.getAllReturnValues().get(0); @@ -695,8 +695,7 @@ public void testRegularReadFirstErrorThenOK() throws Exception { /** * * @param unexpectedCount number of unexpected callback calls - * @param callbackCalled number of callback calls (including unexpected) - * @param dataReceived number of expected callback calls (onBits or onRegisters) + * @param expectedCount number of expected callback calls (onBits or onRegisters) * @param pollStartMillis poll start time in milliepoch * @param expectedPollAverageMin average poll period should be at least greater than this * @param expectedPollAverageMax average poll period less than this @@ -952,7 +951,7 @@ private long getNumberOfOpenClients(SpyingSocketFactory socketSpy) { */ private static class SpyingSocketFactory implements SocketImplFactory { - Queue sockets = new ConcurrentLinkedQueue(); + Queue sockets = new ConcurrentLinkedQueue<>(); @Override public SocketImpl createSocketImpl() { diff --git a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/ValueBufferTest.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/ValueBufferTest.java index e6e29c897fc..94687633412 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/ValueBufferTest.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/ValueBufferTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/WriteRequestJsonUtilitiesTest.java b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/WriteRequestJsonUtilitiesTest.java index 7090b96c8e2..a042a03ac13 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/WriteRequestJsonUtilitiesTest.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/test/java/org/openhab/core/io/transport/modbus/test/WriteRequestJsonUtilitiesTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mqtt/pom.xml b/bundles/org.openhab.core.io.transport.mqtt/pom.xml index fef869a1c19..854dfd57c53 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/pom.xml +++ b/bundles/org.openhab.core.io.transport.mqtt/pom.xml @@ -6,7 +6,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.transport.mqtt diff --git a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttActionCallback.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttActionCallback.java index aacae8ab688..995e4422ccd 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttActionCallback.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttActionCallback.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnection.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnection.java index 05ec2a6c4ff..6de6624206b 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnection.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnection.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -121,7 +121,7 @@ public enum MqttVersion { * The callback will interact with the {@link AbstractReconnectStrategy} as well as inform registered * {@link MqttConnectionObserver}s. */ - public class ConnectionCallback implements MqttClientConnectedListener, MqttClientDisconnectedListener { + public static class ConnectionCallback implements MqttClientConnectedListener, MqttClientDisconnectedListener { private final MqttBrokerConnection connection; private final Runnable cancelTimeoutFuture; private CompletableFuture future = new CompletableFuture<>(); diff --git a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnectionConfig.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnectionConfig.java index 958eb973f15..fc7a4f8ec73 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnectionConfig.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnectionConfig.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -55,7 +55,7 @@ public class MqttBrokerConnectionConfig { */ public String getBrokerID() { final String name = this.name; - if (name != null && name.length() > 0) { + if (name != null && !name.isEmpty()) { return name; } else { StringBuilder b = new StringBuilder(); diff --git a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttConnectionObserver.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttConnectionObserver.java index 392f34ea09f..03499728297 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttConnectionObserver.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttConnectionObserver.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttConnectionState.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttConnectionState.java index b4ab60c3d68..4b7651c157d 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttConnectionState.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttConnectionState.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttException.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttException.java index 7921c0edc8b..76f85b34c30 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttException.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttMessageSubscriber.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttMessageSubscriber.java index 4c3a7246d34..7545f99b235 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttMessageSubscriber.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttMessageSubscriber.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttWillAndTestament.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttWillAndTestament.java index 9ecc752d372..367a1ce5ea6 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttWillAndTestament.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/MqttWillAndTestament.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -72,14 +72,14 @@ public class MqttWillAndTestament { break; case 2: if (!"".equals(value)) { - int tmp = Integer.valueOf(value); + int tmp = Integer.parseInt(value); if (tmp >= 0 && tmp <= 2) { tmpQos = tmp; } } break; case 3: - tmpRetain = Boolean.valueOf(value); + tmpRetain = Boolean.parseBoolean(value); break; } } diff --git a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/internal/Subscription.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/internal/Subscription.java index 84a77d13563..513e9dcd1b7 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/internal/Subscription.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/internal/Subscription.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/internal/client/Mqtt3AsyncClientWrapper.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/internal/client/Mqtt3AsyncClientWrapper.java index 9dc0bf61336..ea89ae45695 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/internal/client/Mqtt3AsyncClientWrapper.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/internal/client/Mqtt3AsyncClientWrapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/internal/client/Mqtt5AsyncClientWrapper.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/internal/client/Mqtt5AsyncClientWrapper.java index 1c4f8ec9ec7..a26276b06ac 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/internal/client/Mqtt5AsyncClientWrapper.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/internal/client/Mqtt5AsyncClientWrapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/internal/client/MqttAsyncClientWrapper.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/internal/client/MqttAsyncClientWrapper.java index fa2f5216854..7fd1336198a 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/internal/client/MqttAsyncClientWrapper.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/internal/client/MqttAsyncClientWrapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/reconnect/AbstractReconnectStrategy.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/reconnect/AbstractReconnectStrategy.java index 9e5ad80cd9b..3db96dbc77d 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/reconnect/AbstractReconnectStrategy.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/reconnect/AbstractReconnectStrategy.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/reconnect/PeriodicReconnectStrategy.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/reconnect/PeriodicReconnectStrategy.java index 85c579efd54..24c2f6ff4d5 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/reconnect/PeriodicReconnectStrategy.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/reconnect/PeriodicReconnectStrategy.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mqtt.reconnect; +import java.util.Objects; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; @@ -105,8 +106,7 @@ public synchronized void lostConnection() { return; } - assert scheduler != null; - scheduledTask = scheduler.scheduleWithFixedDelay(() -> { + scheduledTask = Objects.requireNonNull(scheduler).scheduleWithFixedDelay(() -> { MqttBrokerConnection brokerConnection = this.brokerConnection; // If the broker connections is not available anymore, stop the timed reconnect. if (brokerConnection == null) { diff --git a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/ssl/CustomTrustManagerFactory.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/ssl/CustomTrustManagerFactory.java index a375ec48b6a..e66bd9789f6 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/ssl/CustomTrustManagerFactory.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/openhab/core/io/transport/mqtt/ssl/CustomTrustManagerFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.mqtt/src/test/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnectionEx.java b/bundles/org.openhab.core.io.transport.mqtt/src/test/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnectionEx.java index e5b612ca6be..7ea88508d4d 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/test/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnectionEx.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/test/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnectionEx.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,8 +26,8 @@ import com.hivemq.client.mqtt.MqttClientState; /** - * We need an extended MqttBrokerConnection to overwrite the protected `connectionCallbacks` with - * an instance that takes the mocked version of `MqttBrokerConnection` and overwrite the connection state. + * We need an extended MqttBrokerConnection to overwrite the protected {@link #connectionCallback} with + * an instance that takes the mocked version of {@link MqttBrokerConnection} and overwrite the connection state. * * We also mock the internal Mqtt3AsyncClient that in respect to the success flags * immediately succeed or fail with publish, subscribe, unsubscribe, connect, disconnect. diff --git a/bundles/org.openhab.core.io.transport.mqtt/src/test/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnectionTests.java b/bundles/org.openhab.core.io.transport.mqtt/src/test/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnectionTests.java index 08830da3161..4bc30e9371f 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/test/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnectionTests.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/test/java/org/openhab/core/io/transport/mqtt/MqttBrokerConnectionTests.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -173,7 +173,7 @@ public void reconnectPolicyDefault() throws ConfigurationException, MqttExceptio "MqttBrokerConnectionTests"); // Check if the default policy is set and that the broker within the policy is set. - assertTrue(connection.getReconnectStrategy() instanceof PeriodicReconnectStrategy); + assertInstanceOf(PeriodicReconnectStrategy.class, connection.getReconnectStrategy()); AbstractReconnectStrategy p = connection.getReconnectStrategy(); assertThat(p.getBrokerConnection(), equalTo(connection)); } @@ -331,8 +331,8 @@ public void qosInvalid() throws ConfigurationException { public void setterGetterTests() { MqttBrokerConnectionEx connection = new MqttBrokerConnectionEx("123.123.123.123", null, false, false, "setterGetterTests"); - assertEquals(connection.getHost(), "123.123.123.123", "URL getter"); - assertEquals(connection.getPort(), 1883, "Name getter"); // Check for non-secure port + assertEquals("123.123.123.123", connection.getHost(), "URL getter"); + assertEquals(1883, connection.getPort(), "Name getter"); // Check for non-secure port assertFalse(connection.isSecure(), "Secure getter"); assertFalse(connection.isHostnameValidated(), "HostnameValidated getter"); assertEquals("setterGetterTests", connection.getClientId(), "ClientID getter"); diff --git a/bundles/org.openhab.core.io.transport.serial.javacomm/pom.xml b/bundles/org.openhab.core.io.transport.serial.javacomm/pom.xml index 1d616b0252c..979611b33fc 100644 --- a/bundles/org.openhab.core.io.transport.serial.javacomm/pom.xml +++ b/bundles/org.openhab.core.io.transport.serial.javacomm/pom.xml @@ -6,7 +6,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.transport.serial.javacomm diff --git a/bundles/org.openhab.core.io.transport.serial.javacomm/src/main/java/org/openhab/core/io/transport/serial/internal/JavaCommPortProvider.java b/bundles/org.openhab.core.io.transport.serial.javacomm/src/main/java/org/openhab/core/io/transport/serial/internal/JavaCommPortProvider.java index 57697a1755c..55b3f393c65 100644 --- a/bundles/org.openhab.core.io.transport.serial.javacomm/src/main/java/org/openhab/core/io/transport/serial/internal/JavaCommPortProvider.java +++ b/bundles/org.openhab.core.io.transport.serial.javacomm/src/main/java/org/openhab/core/io/transport/serial/internal/JavaCommPortProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +44,7 @@ public class JavaCommPortProvider implements SerialPortProvider { @Override public @Nullable SerialPortIdentifier getPortIdentifier(URI port) { - CommPortIdentifier ident = null; + CommPortIdentifier ident; try { ident = CommPortIdentifier.getPortIdentifier(port.getPath()); } catch (javax.comm.NoSuchPortException e) { diff --git a/bundles/org.openhab.core.io.transport.serial.javacomm/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortEventImpl.java b/bundles/org.openhab.core.io.transport.serial.javacomm/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortEventImpl.java index 9a77f437b4c..bab70334b07 100644 --- a/bundles/org.openhab.core.io.transport.serial.javacomm/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortEventImpl.java +++ b/bundles/org.openhab.core.io.transport.serial.javacomm/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortEventImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.serial.javacomm/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortIdentifierImpl.java b/bundles/org.openhab.core.io.transport.serial.javacomm/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortIdentifierImpl.java index fe49877dfd7..cc5f5be32c7 100644 --- a/bundles/org.openhab.core.io.transport.serial.javacomm/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortIdentifierImpl.java +++ b/bundles/org.openhab.core.io.transport.serial.javacomm/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortIdentifierImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.serial.javacomm/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortImpl.java b/bundles/org.openhab.core.io.transport.serial.javacomm/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortImpl.java index 021c5539b15..576e0922cb8 100644 --- a/bundles/org.openhab.core.io.transport.serial.javacomm/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortImpl.java +++ b/bundles/org.openhab.core.io.transport.serial.javacomm/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -206,7 +206,7 @@ public void notifyOnCarrierDetect(boolean enable) { @Override public int getFlowControlMode() { - return getFlowControlMode(); + return sp.getFlowControlMode(); } @Override diff --git a/bundles/org.openhab.core.io.transport.serial.rxtx.rfc2217/pom.xml b/bundles/org.openhab.core.io.transport.serial.rxtx.rfc2217/pom.xml index 777820fcc1a..7317a44788c 100644 --- a/bundles/org.openhab.core.io.transport.serial.rxtx.rfc2217/pom.xml +++ b/bundles/org.openhab.core.io.transport.serial.rxtx.rfc2217/pom.xml @@ -6,7 +6,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.transport.serial.rxtx.rfc2217 diff --git a/bundles/org.openhab.core.io.transport.serial.rxtx.rfc2217/src/main/java/org/openhab/core/io/transport/serial/rxtx/rfc2217/internal/RFC2217PortProvider.java b/bundles/org.openhab.core.io.transport.serial.rxtx.rfc2217/src/main/java/org/openhab/core/io/transport/serial/rxtx/rfc2217/internal/RFC2217PortProvider.java index 3a0cd9db4c9..3f7e9e9ddf4 100644 --- a/bundles/org.openhab.core.io.transport.serial.rxtx.rfc2217/src/main/java/org/openhab/core/io/transport/serial/rxtx/rfc2217/internal/RFC2217PortProvider.java +++ b/bundles/org.openhab.core.io.transport.serial.rxtx.rfc2217/src/main/java/org/openhab/core/io/transport/serial/rxtx/rfc2217/internal/RFC2217PortProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.serial.rxtx.rfc2217/src/main/java/org/openhab/core/io/transport/serial/rxtx/rfc2217/internal/SerialPortIdentifierImpl.java b/bundles/org.openhab.core.io.transport.serial.rxtx.rfc2217/src/main/java/org/openhab/core/io/transport/serial/rxtx/rfc2217/internal/SerialPortIdentifierImpl.java index 4083599b8df..43a6cc57d3c 100644 --- a/bundles/org.openhab.core.io.transport.serial.rxtx.rfc2217/src/main/java/org/openhab/core/io/transport/serial/rxtx/rfc2217/internal/SerialPortIdentifierImpl.java +++ b/bundles/org.openhab.core.io.transport.serial.rxtx.rfc2217/src/main/java/org/openhab/core/io/transport/serial/rxtx/rfc2217/internal/SerialPortIdentifierImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.serial.rxtx/pom.xml b/bundles/org.openhab.core.io.transport.serial.rxtx/pom.xml index 0625bfedf7d..e505f69fdef 100644 --- a/bundles/org.openhab.core.io.transport.serial.rxtx/pom.xml +++ b/bundles/org.openhab.core.io.transport.serial.rxtx/pom.xml @@ -6,7 +6,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.transport.serial.rxtx diff --git a/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/RxTxPortProvider.java b/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/RxTxPortProvider.java index a519833dd09..2ae487d955e 100644 --- a/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/RxTxPortProvider.java +++ b/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/RxTxPortProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortEventImpl.java b/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortEventImpl.java index 5dff9bc0701..29d7aa985b0 100644 --- a/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortEventImpl.java +++ b/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortEventImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortIdentifierImpl.java b/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortIdentifierImpl.java index f0d34267171..fbe105ac38e 100644 --- a/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortIdentifierImpl.java +++ b/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortIdentifierImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortUtil.java b/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortUtil.java index 8297134e538..c0d31d8cee4 100644 --- a/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortUtil.java +++ b/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -107,15 +107,14 @@ public static synchronized Stream getPortIdentifiersUsingPro static @Nullable String initSerialPort(String port, @Nullable String serialPortsProperty) { String pathSeparator = File.pathSeparator; - Set serialPorts = null; + Set serialPorts; if (serialPortsProperty != null) { serialPorts = Stream.of(serialPortsProperty.split(pathSeparator)).collect(Collectors.toSet()); } else { serialPorts = new HashSet<>(); } if (serialPorts.add(port)) { - return serialPorts.stream().collect(Collectors.joining(pathSeparator)); // see - // RXTXCommDriver#addSpecifiedPorts + return String.join(pathSeparator, serialPorts); // see RXTXCommDriver#addSpecifiedPorts } return null; } diff --git a/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/rxtx/RxTxSerialPort.java b/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/rxtx/RxTxSerialPort.java index 90f7e6eebc1..da9962eaa7b 100644 --- a/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/rxtx/RxTxSerialPort.java +++ b/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/openhab/core/io/transport/serial/rxtx/RxTxSerialPort.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -206,7 +206,7 @@ public void notifyOnCarrierDetect(boolean enable) { @Override public int getFlowControlMode() { - return getFlowControlMode(); + return sp.getFlowControlMode(); } @Override diff --git a/bundles/org.openhab.core.io.transport.serial/pom.xml b/bundles/org.openhab.core.io.transport.serial/pom.xml index 7336a370aef..dc6933efa7f 100644 --- a/bundles/org.openhab.core.io.transport.serial/pom.xml +++ b/bundles/org.openhab.core.io.transport.serial/pom.xml @@ -6,7 +6,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.transport.serial diff --git a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/PortInUseException.java b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/PortInUseException.java index d3f9a1efd7a..03a475d4764 100644 --- a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/PortInUseException.java +++ b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/PortInUseException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/ProtocolType.java b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/ProtocolType.java index 6138974ed1f..6173f96febe 100644 --- a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/ProtocolType.java +++ b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/ProtocolType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPort.java b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPort.java index 5d4f629dad2..49e899567d8 100644 --- a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPort.java +++ b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPort.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,23 +34,23 @@ @NonNullByDefault public interface SerialPort extends Closeable { - final int DATABITS_5 = 5; - final int DATABITS_6 = 6; - final int DATABITS_7 = 7; - final int DATABITS_8 = 8; - final int PARITY_NONE = 0; - final int PARITY_ODD = 1; - final int PARITY_EVEN = 2; - final int PARITY_MARK = 3; - final int PARITY_SPACE = 4; - final int STOPBITS_1 = 1; - final int STOPBITS_2 = 2; - final int STOPBITS_1_5 = 3; - final int FLOWCONTROL_NONE = 0; - final int FLOWCONTROL_RTSCTS_IN = 1; - final int FLOWCONTROL_RTSCTS_OUT = 2; - final int FLOWCONTROL_XONXOFF_IN = 4; - final int FLOWCONTROL_XONXOFF_OUT = 8; + int DATABITS_5 = 5; + int DATABITS_6 = 6; + int DATABITS_7 = 7; + int DATABITS_8 = 8; + int PARITY_NONE = 0; + int PARITY_ODD = 1; + int PARITY_EVEN = 2; + int PARITY_MARK = 3; + int PARITY_SPACE = 4; + int STOPBITS_1 = 1; + int STOPBITS_2 = 2; + int STOPBITS_1_5 = 3; + int FLOWCONTROL_NONE = 0; + int FLOWCONTROL_RTSCTS_IN = 1; + int FLOWCONTROL_RTSCTS_OUT = 2; + int FLOWCONTROL_XONXOFF_IN = 4; + int FLOWCONTROL_XONXOFF_OUT = 8; @Override void close(); diff --git a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortEvent.java b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortEvent.java index 4dfed01bba5..34db1bcaa58 100644 --- a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortEvent.java +++ b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,16 +21,17 @@ */ @NonNullByDefault public interface SerialPortEvent { - final int DATA_AVAILABLE = 1; - final int OUTPUT_BUFFER_EMPTY = 2; - final int CTS = 3; - final int DSR = 4; - final int RI = 5; - final int CD = 6; - final int OE = 7; - final int PE = 8; - final int FE = 9; - final int BI = 10; + int DATA_AVAILABLE = 1; + int OUTPUT_BUFFER_EMPTY = 2; + int CTS = 3; + int DSR = 4; + int RI = 5; + int CD = 6; + int OE = 7; + int PE = 8; + int FE = 9; + int BI = 10; + int PORT_DISCONNECTED = 11; /** * Get the type of the event. diff --git a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortEventListener.java b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortEventListener.java index 96dd3b96c47..3594df583f6 100644 --- a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortEventListener.java +++ b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortEventListener.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortIdentifier.java b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortIdentifier.java index 7b1af08a28b..9beed026ff3 100644 --- a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortIdentifier.java +++ b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortIdentifier.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortManager.java b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortManager.java index 48a6b0cd5fb..91ed941f318 100644 --- a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortManager.java +++ b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortManager.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortProvider.java b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortProvider.java index caf68b4fe47..3bf46df37aa 100644 --- a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortProvider.java +++ b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/SerialPortProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -30,8 +30,7 @@ public interface SerialPortProvider { * Gets the {@link SerialPortIdentifier} if it is available or null otherwise. * * @param portName The ports name. - * @return The created {@link SerialPort}. - * @throws NoSuchPortException If the serial port does not exist. + * @return The created {@link SerialPort} or null if the serial port does not exist. * @throws UnsupportedCommOperationException * @throws PortInUseException */ diff --git a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/UnsupportedCommOperationException.java b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/UnsupportedCommOperationException.java index 6457533fb9b..73b4b160bfb 100644 --- a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/UnsupportedCommOperationException.java +++ b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/UnsupportedCommOperationException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortManagerImpl.java b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortManagerImpl.java index 69526224359..64d9c0a0e34 100644 --- a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortManagerImpl.java +++ b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortManagerImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortRegistry.java b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortRegistry.java index f979ad759f8..8b71af1eb92 100644 --- a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortRegistry.java +++ b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/SerialPortRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,12 +70,10 @@ public Collection getPortProvidersForPortName(URI portName) final Predicate filter; if (scheme != null) { // Get port providers which accept exactly the port with its scheme. - filter = provider -> provider.getAcceptedProtocols().filter(prot -> prot.getScheme().equals(scheme)) - .count() > 0; + filter = provider -> provider.getAcceptedProtocols().anyMatch(prot -> prot.getScheme().equals(scheme)); } else { // Get port providers which accept the same type (local, net) - filter = provider -> provider.getAcceptedProtocols().filter(prot -> prot.getPathType().equals(pathType)) - .count() > 0; + filter = provider -> provider.getAcceptedProtocols().anyMatch(prot -> prot.getPathType().equals(pathType)); } return portCreators.stream().filter(filter).toList(); diff --git a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/console/SerialCommandExtension.java b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/console/SerialCommandExtension.java index ec34da00f08..36f48fad343 100644 --- a/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/console/SerialCommandExtension.java +++ b/bundles/org.openhab.core.io.transport.serial/src/main/java/org/openhab/core/io/transport/serial/internal/console/SerialCommandExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.upnp/pom.xml b/bundles/org.openhab.core.io.transport.upnp/pom.xml index b9de5808c82..cc348f7c062 100644 --- a/bundles/org.openhab.core.io.transport.upnp/pom.xml +++ b/bundles/org.openhab.core.io.transport.upnp/pom.xml @@ -6,7 +6,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.transport.upnp diff --git a/bundles/org.openhab.core.io.transport.upnp/src/main/java/org/openhab/core/io/transport/upnp/UpnpIOParticipant.java b/bundles/org.openhab.core.io.transport.upnp/src/main/java/org/openhab/core/io/transport/upnp/UpnpIOParticipant.java index f85db550044..f26a009cc2b 100644 --- a/bundles/org.openhab.core.io.transport.upnp/src/main/java/org/openhab/core/io/transport/upnp/UpnpIOParticipant.java +++ b/bundles/org.openhab.core.io.transport.upnp/src/main/java/org/openhab/core/io/transport/upnp/UpnpIOParticipant.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.upnp/src/main/java/org/openhab/core/io/transport/upnp/UpnpIOService.java b/bundles/org.openhab.core.io.transport.upnp/src/main/java/org/openhab/core/io/transport/upnp/UpnpIOService.java index 69366df89c3..64a6e83ba96 100644 --- a/bundles/org.openhab.core.io.transport.upnp/src/main/java/org/openhab/core/io/transport/upnp/UpnpIOService.java +++ b/bundles/org.openhab.core.io.transport.upnp/src/main/java/org/openhab/core/io/transport/upnp/UpnpIOService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.transport.upnp/src/main/java/org/openhab/core/io/transport/upnp/internal/UpnpIOServiceImpl.java b/bundles/org.openhab.core.io.transport.upnp/src/main/java/org/openhab/core/io/transport/upnp/internal/UpnpIOServiceImpl.java index c5143322e07..b417714002e 100644 --- a/bundles/org.openhab.core.io.transport.upnp/src/main/java/org/openhab/core/io/transport/upnp/internal/UpnpIOServiceImpl.java +++ b/bundles/org.openhab.core.io.transport.upnp/src/main/java/org/openhab/core/io/transport/upnp/internal/UpnpIOServiceImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 @@ import java.net.URL; import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; import java.util.Objects; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -154,11 +155,11 @@ protected void eventReceived(GENASubscription sub) { deviceRoot.getIdentity().getUdn()); for (UpnpIOParticipant participant : participants) { if (Objects.equals(getDevice(participant), deviceRoot)) { - for (String stateVariable : values.keySet()) { - StateVariableValue value = values.get(stateVariable); - if (value.getValue() != null) { + for (Entry entry : values.entrySet()) { + Object value = entry.getValue().getValue(); + if (value != null) { try { - participant.onValueReceived(stateVariable, value.getValue().toString(), serviceId); + participant.onValueReceived(entry.getKey(), value.toString(), serviceId); } catch (Exception e) { logger.error("Participant threw an exception onValueReceived", e); } @@ -300,8 +301,8 @@ public Map invokeAction(UpnpIOParticipant participant, String se if (action != null) { ActionInvocation invocation = new ActionInvocation(action); if (inputs != null) { - for (String variable : inputs.keySet()) { - invocation.setInput(variable, inputs.get(variable)); + for (Entry entry : inputs.entrySet()) { + invocation.setInput(entry.getKey(), entry.getValue()); } } @@ -316,10 +317,11 @@ public Map invokeAction(UpnpIOParticipant participant, String se Map result = invocation.getOutputMap(); if (result != null) { - for (String variable : result.keySet()) { + for (Entry entry : result.entrySet()) { + String variable = entry.getKey(); final ActionArgumentValue newArgument; try { - newArgument = result.get(variable); + newArgument = entry.getValue(); } catch (final Exception ex) { logger.debug("An exception '{}' occurred, cannot get argument for variable '{}'", ex.getMessage(), variable); @@ -383,7 +385,7 @@ public URL getDescriptorURL(UpnpIOParticipant participant) { } private Service findService(Device device, String serviceID) { - Service service = null; + Service service; String namespace = device.getType().getNamespace(); if (UDAServiceId.DEFAULT_NAMESPACE.equals(namespace) || UDAServiceId.BROKEN_DEFAULT_NAMESPACE.equals(namespace)) { diff --git a/bundles/org.openhab.core.io.transport.upnp/src/test/java/org/openhab/core/io/transport/upnp/internal/UpnpIOServiceTest.java b/bundles/org.openhab.core.io.transport.upnp/src/test/java/org/openhab/core/io/transport/upnp/internal/UpnpIOServiceTest.java index 0e57911407e..43fbed7e9a1 100644 --- a/bundles/org.openhab.core.io.transport.upnp/src/test/java/org/openhab/core/io/transport/upnp/internal/UpnpIOServiceTest.java +++ b/bundles/org.openhab.core.io.transport.upnp/src/test/java/org/openhab/core/io/transport/upnp/internal/UpnpIOServiceTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.websocket/pom.xml b/bundles/org.openhab.core.io.websocket/pom.xml index dca8a41f81e..1dcd49b79aa 100644 --- a/bundles/org.openhab.core.io.websocket/pom.xml +++ b/bundles/org.openhab.core.io.websocket/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.io.websocket diff --git a/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/CommonWebSocketServlet.java b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/CommonWebSocketServlet.java index 7937ef0e39b..8109e5dd161 100644 --- a/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/CommonWebSocketServlet.java +++ b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/CommonWebSocketServlet.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -30,6 +30,7 @@ import org.openhab.core.auth.AuthenticationException; import org.openhab.core.auth.Role; import org.openhab.core.io.rest.auth.AuthFilter; +import org.openhab.core.io.websocket.event.EventWebSocketAdapter; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; diff --git a/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/WebSocketAdapter.java b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/WebSocketAdapter.java index ecf9263010b..c5c5e77b774 100644 --- a/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/WebSocketAdapter.java +++ b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/WebSocketAdapter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.io.websocket/src/main/java/org/openhab/core/io/websocket/EventDTO.java b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/event/EventDTO.java similarity index 95% rename from bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/EventDTO.java rename to bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/event/EventDTO.java index 6038e41c929..0bc1c229999 100644 --- a/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/EventDTO.java +++ b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/event/EventDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.core.io.websocket; +package org.openhab.core.io.websocket.event; import java.util.Objects; diff --git a/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/EventProcessingException.java b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/event/EventProcessingException.java similarity index 87% rename from bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/EventProcessingException.java rename to bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/event/EventProcessingException.java index b2a504ea61e..19027809414 100644 --- a/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/EventProcessingException.java +++ b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/event/EventProcessingException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.core.io.websocket; +package org.openhab.core.io.websocket.event; import org.eclipse.jdt.annotation.NonNullByDefault; diff --git a/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/EventWebSocket.java b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/event/EventWebSocket.java similarity index 94% rename from bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/EventWebSocket.java rename to bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/event/EventWebSocket.java index f37bb4cc8e2..7e08222d50e 100644 --- a/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/EventWebSocket.java +++ b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/event/EventWebSocket.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.core.io.websocket; +package org.openhab.core.io.websocket.event; import java.io.IOException; import java.lang.reflect.Type; @@ -123,6 +123,12 @@ public void onText(String message) { responseEvent = new EventDTO(WEBSOCKET_EVENT_TYPE, WEBSOCKET_TOPIC_PREFIX + "response/success", "", null, eventDTO.eventId); break; + case "ItemTimeSeriesEvent": + Event itemTimeseriesEvent = itemEventUtility.createTimeSeriesEvent(eventDTO); + eventPublisher.post(itemTimeseriesEvent); + responseEvent = new EventDTO(WEBSOCKET_EVENT_TYPE, WEBSOCKET_TOPIC_PREFIX + "response/success", + "", null, eventDTO.eventId); + break; case WEBSOCKET_EVENT_TYPE: if ((WEBSOCKET_TOPIC_PREFIX + "heartbeat").equals(eventDTO.topic) && "PING".equals(eventDTO.payload)) { diff --git a/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/EventWebSocketAdapter.java b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/event/EventWebSocketAdapter.java similarity index 94% rename from bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/EventWebSocketAdapter.java rename to bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/event/EventWebSocketAdapter.java index 6ef61b804cb..f97b706639a 100644 --- a/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/EventWebSocketAdapter.java +++ b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/event/EventWebSocketAdapter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.core.io.websocket; +package org.openhab.core.io.websocket.event; import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; @@ -21,6 +21,7 @@ import org.openhab.core.events.Event; import org.openhab.core.events.EventPublisher; import org.openhab.core.events.EventSubscriber; +import org.openhab.core.io.websocket.WebSocketAdapter; import org.openhab.core.items.ItemRegistry; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; diff --git a/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/ItemEventUtility.java b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/event/ItemEventUtility.java similarity index 64% rename from bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/ItemEventUtility.java rename to bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/event/ItemEventUtility.java index e8f1d2b9ec9..1118a4750f2 100644 --- a/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/ItemEventUtility.java +++ b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/event/ItemEventUtility.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -10,8 +10,10 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.core.io.websocket; +package org.openhab.core.io.websocket.event; +import java.time.Instant; +import java.time.format.DateTimeParseException; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -26,6 +28,7 @@ import org.openhab.core.types.Command; import org.openhab.core.types.RefreshType; import org.openhab.core.types.State; +import org.openhab.core.types.TimeSeries; import org.openhab.core.types.Type; import org.openhab.core.types.TypeParser; import org.openhab.core.types.UnDefType; @@ -78,6 +81,13 @@ public Event createStateEvent(EventDTO eventDTO) throws EventProcessingException throw new EventProcessingException("Incompatible datatype, rejected."); } + public Event createTimeSeriesEvent(EventDTO eventDTO) throws EventProcessingException { + Matcher matcher = getTopicMatcher(eventDTO.topic, "timeseries"); + Item item = getItem(matcher.group("entity")); + TimeSeries timeSeries = parseTimeSeries(eventDTO.payload); + return ItemEventFactory.createTimeSeriesEvent(item.getName(), timeSeries, eventDTO.source); + } + private Matcher getTopicMatcher(@Nullable String topic, String action) throws EventProcessingException { if (topic == null) { throw new EventProcessingException("Topic must not be null"); @@ -102,6 +112,36 @@ private Item getItem(String itemName) throws EventProcessingException { } } + private TimeSeries parseTimeSeries(@Nullable String payload) throws EventProcessingException { + ItemTimeSeriesEventPayloadBean bean = null; + try { + bean = gson.fromJson(payload, ItemTimeSeriesEventPayloadBean.class); + } catch (JsonParseException ignored) { + } + if (bean == null) { + throw new EventProcessingException("Failed to deserialize payload '" + payload + "'."); + } + + TimeSeries timeSeries = new TimeSeries(TimeSeries.Policy.valueOf(bean.policy)); + + for (ItemTimeSeriesEventPayloadBean.TimeSeriesPayload timeSeriesPayload : bean.timeSeries) { + Type value = parseType(timeSeriesPayload.type, timeSeriesPayload.value); + if (value instanceof State state) { + try { + Instant timestamp = Instant.parse(timeSeriesPayload.timestamp); + timeSeries.add(timestamp, state); + } catch (DateTimeParseException e) { + throw new EventProcessingException( + "Could not parse '" + timeSeriesPayload.timestamp + "' to an instant."); + } + } else { + throw new EventProcessingException("Only states are allowed in timeseries events."); + } + } + + return timeSeries; + } + private Type parseType(@Nullable String payload) throws EventProcessingException { ItemEventPayloadBean bean = null; try { @@ -112,20 +152,24 @@ private Type parseType(@Nullable String payload) throws EventProcessingException throw new EventProcessingException("Failed to deserialize payload '" + payload + "'."); } - String simpleClassName = bean.type + TYPE_POSTFIX; + return parseType(bean.type, bean.value); + } + + private Type parseType(String type, String value) throws EventProcessingException { + String simpleClassName = type + TYPE_POSTFIX; Type returnType; if (simpleClassName.equals(UnDefType.class.getSimpleName())) { - returnType = UnDefType.valueOf(bean.value); + returnType = UnDefType.valueOf(value); } else if (simpleClassName.equals(RefreshType.class.getSimpleName())) { - returnType = RefreshType.valueOf(bean.value); + returnType = RefreshType.valueOf(value); } else { - returnType = TypeParser.parseType(simpleClassName, bean.value); + returnType = TypeParser.parseType(simpleClassName, value); } if (returnType == null) { throw new EventProcessingException( - "Error parsing simpleClassName '" + simpleClassName + "' with value '" + bean.value + "'."); + "Error parsing simpleClassName '" + simpleClassName + "' with value '" + value + "'."); } return returnType; @@ -135,4 +179,15 @@ private static class ItemEventPayloadBean { public @NonNullByDefault({}) String type; public @NonNullByDefault({}) String value; } + + private static class ItemTimeSeriesEventPayloadBean { + private @NonNullByDefault({}) List timeSeries; + private @NonNullByDefault({}) String policy; + + private static class TimeSeriesPayload { + private @NonNullByDefault({}) String type; + private @NonNullByDefault({}) String value; + private @NonNullByDefault({}) String timestamp; + } + } } diff --git a/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/log/LogDTO.java b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/log/LogDTO.java new file mode 100644 index 00000000000..3d07ed4f7bc --- /dev/null +++ b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/log/LogDTO.java @@ -0,0 +1,34 @@ +/** + * 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.io.websocket.log; + +import java.util.Date; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.core.io.websocket.event.EventDTO; +import org.osgi.service.log.LogLevel; + +/** + * The {@link EventDTO} is used for serialization and deserialization of events + * + * @author Jan N. Klug - Initial contribution + */ +@NonNullByDefault +public class LogDTO { + public @Nullable String loggerName; + public @Nullable LogLevel level; + public @Nullable Date timestamp; + public long unixtime; + public @Nullable String message; +} diff --git a/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/log/LogWebSocket.java b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/log/LogWebSocket.java new file mode 100644 index 00000000000..d2294bccb65 --- /dev/null +++ b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/log/LogWebSocket.java @@ -0,0 +1,148 @@ +/** + * 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.io.websocket.log; + +import java.io.IOException; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.function.Predicate; +import java.util.regex.Pattern; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.jetty.websocket.api.RemoteEndpoint; +import org.eclipse.jetty.websocket.api.Session; +import org.eclipse.jetty.websocket.api.StatusCode; +import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; +import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; +import org.eclipse.jetty.websocket.api.annotations.OnWebSocketError; +import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; +import org.eclipse.jetty.websocket.api.annotations.WebSocket; +import org.osgi.service.log.LogEntry; +import org.osgi.service.log.LogListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gson.Gson; +import com.google.gson.JsonParseException; +import com.google.gson.reflect.TypeToken; + +/** + * The {@link LogWebSocket} is the WebSocket implementation for logs + * + * @author Jan N. Klug - Initial contribution + */ +@WebSocket +@NonNullByDefault +@SuppressWarnings("unused") +public class LogWebSocket implements LogListener { + @SuppressWarnings("unchecked") + private static final TypeToken> STRING_LIST_TYPE = (TypeToken>) TypeToken + .getParameterized(List.class, String.class); + + private final Logger logger = LoggerFactory.getLogger(LogWebSocket.class); + + private final LogWebSocketAdapter wsAdapter; + private final Gson gson; + + private @Nullable Session session; + private @Nullable RemoteEndpoint remoteEndpoint; + private String remoteIdentifier = ""; + + private List loggerPatterns = List.of(); + + public LogWebSocket(Gson gson, LogWebSocketAdapter wsAdapter) { + this.wsAdapter = wsAdapter; + this.gson = gson; + } + + @OnWebSocketClose + public void onClose(int statusCode, String reason) { + this.wsAdapter.unregisterListener(this); + remoteIdentifier = ""; + this.session = null; + this.remoteEndpoint = null; + } + + @OnWebSocketConnect + public void onConnect(Session session) { + this.session = session; + RemoteEndpoint remoteEndpoint = session.getRemote(); + this.remoteEndpoint = remoteEndpoint; + this.remoteIdentifier = remoteEndpoint.getInetSocketAddress().toString(); + this.wsAdapter.registerListener(this); + } + + @OnWebSocketMessage + public void onText(String message) { + RemoteEndpoint remoteEndpoint = this.remoteEndpoint; + if (session == null || remoteEndpoint == null) { + // no connection or no remote endpoint , do nothing this is possible due to async behavior + return; + } + + try { + loggerPatterns = gson.fromJson(message, STRING_LIST_TYPE).stream().map(Pattern::compile).toList(); + } catch (JsonParseException e) { + logger.warn("Failed to parse '{}' to a list of subscribed loggers", message); + } + } + + @OnWebSocketError + public void onError(Session session, @Nullable Throwable error) { + if (session != null) { + session.close(); + } + + String message = error == null ? "" : Objects.requireNonNullElse(error.getMessage(), ""); + logger.info("WebSocket error: {}", message); + onClose(StatusCode.NO_CODE, message); + } + + private synchronized void sendMessage(String message) throws IOException { + RemoteEndpoint remoteEndpoint = this.remoteEndpoint; + if (remoteEndpoint == null) { + logger.warn("Could not determine remote endpoint, failed to send '{}'.", message); + return; + } + remoteEndpoint.sendString(message); + } + + @Override + public void logged(@NonNullByDefault({}) LogEntry logEntry) { + if (!loggerPatterns.isEmpty() && loggerPatterns.stream().noneMatch(logMatch(logEntry))) { + return; + } + try { + LogDTO logDTO = map(logEntry); + sendMessage(gson.toJson(logDTO)); + } catch (IOException e) { + logger.debug("Failed to send log {} to {}: {}", logEntry, remoteIdentifier, e.getMessage()); + } + } + + private static Predicate logMatch(LogEntry logEntry) { + return pattern -> pattern.matcher(logEntry.getLoggerName()).matches(); + } + + private static LogDTO map(LogEntry logEntry) { + LogDTO logDTO = new LogDTO(); + logDTO.loggerName = logEntry.getLoggerName(); + logDTO.level = logEntry.getLogLevel(); + logDTO.unixtime = logEntry.getTime(); + logDTO.timestamp = new Date(logEntry.getTime()); + logDTO.message = logEntry.getMessage(); + return logDTO; + } +} diff --git a/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/log/LogWebSocketAdapter.java b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/log/LogWebSocketAdapter.java new file mode 100644 index 00000000000..f997b6456fc --- /dev/null +++ b/bundles/org.openhab.core.io.websocket/src/main/java/org/openhab/core/io/websocket/log/LogWebSocketAdapter.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.io.websocket.log; + +import java.util.Set; +import java.util.concurrent.CopyOnWriteArraySet; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest; +import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse; +import org.openhab.core.io.websocket.WebSocketAdapter; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.log.LogReaderService; + +import com.google.gson.Gson; + +/** + * The {@link LogWebSocketAdapter} allows subscription to log events over WebSocket + * + * @author Jan N. Klug - Initial contribution + */ +@NonNullByDefault +@Component(immediate = true, service = { WebSocketAdapter.class }) +public class LogWebSocketAdapter implements WebSocketAdapter { + public static final String ADAPTER_ID = "logs"; + private final Gson gson = new Gson(); + private final Set webSockets = new CopyOnWriteArraySet<>(); + private final LogReaderService logReaderService; + + @Activate + public LogWebSocketAdapter(@Reference LogReaderService logReaderService) { + this.logReaderService = logReaderService; + } + + @Deactivate + public void deactivate() { + webSockets.forEach(logReaderService::removeLogListener); + } + + public void registerListener(LogWebSocket eventWebSocket) { + webSockets.add(eventWebSocket); + logReaderService.addLogListener(eventWebSocket); + } + + public void unregisterListener(LogWebSocket eventWebSocket) { + logReaderService.removeLogListener(eventWebSocket); + webSockets.remove(eventWebSocket); + } + + @Override + public String getId() { + return ADAPTER_ID; + } + + @Override + public Object createWebSocket(ServletUpgradeRequest servletUpgradeRequest, + ServletUpgradeResponse servletUpgradeResponse) { + return new LogWebSocket(gson, LogWebSocketAdapter.this); + } +} diff --git a/bundles/org.openhab.core.io.websocket/src/test/java/org/openhab/core/io/websocket/CommonWebSocketServletTest.java b/bundles/org.openhab.core.io.websocket/src/test/java/org/openhab/core/io/websocket/CommonWebSocketServletTest.java index c7aafb587dc..7c964ddee65 100644 --- a/bundles/org.openhab.core.io.websocket/src/test/java/org/openhab/core/io/websocket/CommonWebSocketServletTest.java +++ b/bundles/org.openhab.core.io.websocket/src/test/java/org/openhab/core/io/websocket/CommonWebSocketServletTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 @@ import org.openhab.core.auth.AuthenticationException; import org.openhab.core.io.rest.auth.AnonymousUserSecurityContext; import org.openhab.core.io.rest.auth.AuthFilter; +import org.openhab.core.io.websocket.event.EventWebSocket; import org.osgi.service.http.NamespaceException; /** diff --git a/bundles/org.openhab.core.io.websocket/src/test/java/org/openhab/core/io/websocket/EventWebSocketTest.java b/bundles/org.openhab.core.io.websocket/src/test/java/org/openhab/core/io/websocket/EventWebSocketTest.java index 49eb37596de..e194cab51bf 100644 --- a/bundles/org.openhab.core.io.websocket/src/test/java/org/openhab/core/io/websocket/EventWebSocketTest.java +++ b/bundles/org.openhab.core.io.websocket/src/test/java/org/openhab/core/io/websocket/EventWebSocketTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,8 +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.io.websocket.EventWebSocket.WEBSOCKET_EVENT_TYPE; -import static org.openhab.core.io.websocket.EventWebSocket.WEBSOCKET_TOPIC_PREFIX; +import static org.openhab.core.io.websocket.event.EventWebSocket.WEBSOCKET_EVENT_TYPE; +import static org.openhab.core.io.websocket.event.EventWebSocket.WEBSOCKET_TOPIC_PREFIX; import java.io.IOException; import java.net.InetSocketAddress; @@ -39,6 +39,10 @@ import org.mockito.quality.Strictness; import org.openhab.core.events.Event; import org.openhab.core.events.EventPublisher; +import org.openhab.core.io.websocket.event.EventDTO; +import org.openhab.core.io.websocket.event.EventWebSocket; +import org.openhab.core.io.websocket.event.EventWebSocketAdapter; +import org.openhab.core.io.websocket.event.ItemEventUtility; import org.openhab.core.items.ItemNotFoundException; import org.openhab.core.items.ItemRegistry; import org.openhab.core.items.events.ItemEventFactory; diff --git a/bundles/org.openhab.core.io.websocket/src/test/java/org/openhab/core/io/websocket/ItemEventUtilityTest.java b/bundles/org.openhab.core.io.websocket/src/test/java/org/openhab/core/io/websocket/ItemEventUtilityTest.java index 081c31146cf..6b53e9f5219 100644 --- a/bundles/org.openhab.core.io.websocket/src/test/java/org/openhab/core/io/websocket/ItemEventUtilityTest.java +++ b/bundles/org.openhab.core.io.websocket/src/test/java/org/openhab/core/io/websocket/ItemEventUtilityTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ArgumentMatchers.eq; import static org.mockito.Mockito.when; +import java.time.Instant; + import org.eclipse.jdt.annotation.NonNullByDefault; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -27,14 +29,20 @@ import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; import org.openhab.core.events.Event; +import org.openhab.core.io.websocket.event.EventDTO; +import org.openhab.core.io.websocket.event.EventProcessingException; +import org.openhab.core.io.websocket.event.ItemEventUtility; import org.openhab.core.items.ItemNotFoundException; import org.openhab.core.items.ItemRegistry; import org.openhab.core.items.events.ItemEvent; import org.openhab.core.items.events.ItemEventFactory; +import org.openhab.core.items.events.ItemTimeSeriesEvent; import org.openhab.core.library.items.StringItem; import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.HSBType; +import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.StringType; +import org.openhab.core.types.TimeSeries; import com.google.gson.Gson; @@ -168,4 +176,17 @@ public void invalidCommandEventPayload() { () -> itemEventUtility.createCommandEvent(eventDTO)); assertThat(e.getMessage(), is("Failed to deserialize payload 'invalidNoJson'.")); } + + @Test + public void validTimeSeriesEvent() throws EventProcessingException { + TimeSeries timeSeries = new TimeSeries(TimeSeries.Policy.REPLACE); + timeSeries.add(Instant.now(), OnOffType.ON); + timeSeries.add(Instant.now().plusSeconds(5), OnOffType.OFF); + ItemTimeSeriesEvent event = ItemEventFactory.createTimeSeriesEvent(EXISTING_ITEM_NAME, timeSeries, null); + EventDTO eventDTO = new EventDTO(event); + + Event itemEvent = itemEventUtility.createTimeSeriesEvent(eventDTO); + + assertThat(itemEvent, is(event)); + } } diff --git a/bundles/org.openhab.core.karaf/pom.xml b/bundles/org.openhab.core.karaf/pom.xml index 97267744d35..0873cdf66ca 100644 --- a/bundles/org.openhab.core.karaf/pom.xml +++ b/bundles/org.openhab.core.karaf/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.karaf @@ -30,6 +30,11 @@ org.openhab.core.config.core ${project.version} + + org.openhab.core.bundles + org.openhab.core.config.discovery.addon + ${project.version} + org.apache.karaf.features org.apache.karaf.features.core diff --git a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/FeatureInstaller.java b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/FeatureInstaller.java index 0d22594c6fd..28c8ae555e6 100644 --- a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/FeatureInstaller.java +++ b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/FeatureInstaller.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.karaf/src/main/java/org/openhab/core/karaf/internal/KarafAddonFinderService.java b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/KarafAddonFinderService.java new file mode 100644 index 00000000000..391e742ae9c --- /dev/null +++ b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/KarafAddonFinderService.java @@ -0,0 +1,78 @@ +/** + * 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.karaf.internal; + +import org.apache.karaf.features.FeaturesService; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.core.config.discovery.addon.AddonFinderService; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This service is an implementation of an openHAB {@link AddonFinderService} using the Karaf features + * service. This service allows dynamic installation/removal of add-on suggestion finders. + * + * @author Mark Herwege - Initial contribution + */ +@Component(name = "org.openhab.core.karafaddonfinders", immediate = true) +@NonNullByDefault +public class KarafAddonFinderService implements AddonFinderService { + private final Logger logger = LoggerFactory.getLogger(KarafAddonFinderService.class); + + private final FeaturesService featuresService; + private boolean deactivated; + + @Activate + public KarafAddonFinderService(final @Reference FeaturesService featuresService) { + this.featuresService = featuresService; + } + + @Deactivate + protected void deactivate() { + deactivated = true; + } + + @Override + public void install(String id) { + if (!deactivated) { + try { + if (!featuresService.isInstalled(featuresService.getFeature(id))) { + featuresService.installFeature(id); + } + } catch (Exception e) { + if (!deactivated) { + logger.error("Failed to install add-on suggestion finder {}", id, e); + } + } + } + } + + @Override + public void uninstall(String id) { + if (!deactivated) { + try { + if (featuresService.isInstalled(featuresService.getFeature(id))) { + featuresService.uninstallFeature(id); + } + } catch (Exception e) { + if (!deactivated) { + logger.error("Failed to uninstall add-on suggestion finder {}", id, e); + } + } + } + } +} diff --git a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/KarafAddonService.java b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/KarafAddonService.java index 8e422715568..cb70c7c1db5 100644 --- a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/KarafAddonService.java +++ b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/KarafAddonService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -133,10 +133,13 @@ private Addon getAddon(Feature feature, @Nullable Locale locale) { AddonInfo addonInfo = addonInfoRegistry.getAddonInfo(uid, locale); - if (isInstalled && 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 != null) { + if (addonInfo.isMasterAddonInfo()) { + addon = addon.withLabel(addonInfo.getName()).withDescription(addonInfo.getDescription()); + } else { + addon = addon.withLabel(feature.getDescription()); + } + addon = addon.withConnection(addonInfo.getConnection()).withCountries(addonInfo.getCountries()) .withLink(getDefaultDocumentationLink(type, name)) .withConfigDescriptionURI(addonInfo.getConfigDescriptionURI()); } else { diff --git a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/LoggerBean.java b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/LoggerBean.java index 4b29642fa9f..1c7a1cfc991 100644 --- a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/LoggerBean.java +++ b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/LoggerBean.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.karaf/src/main/java/org/openhab/core/karaf/internal/LoggerResource.java b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/LoggerResource.java index 184e77404a1..b633b74e52e 100644 --- a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/LoggerResource.java +++ b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/LoggerResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.karaf/src/main/java/org/openhab/core/karaf/internal/jaas/ManagedUserBackingEngine.java b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/jaas/ManagedUserBackingEngine.java index 4e15e89e713..829a77cdd03 100644 --- a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/jaas/ManagedUserBackingEngine.java +++ b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/jaas/ManagedUserBackingEngine.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -42,7 +42,7 @@ public ManagedUserBackingEngine(UserRegistry userRegistry) { @Override public void addUser(String username, String password) { - userRegistry.register(username, password, new HashSet(Set.of(Role.USER))); + userRegistry.register(username, password, new HashSet<>(Set.of(Role.USER))); } @Override diff --git a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/jaas/ManagedUserBackingEngineFactory.java b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/jaas/ManagedUserBackingEngineFactory.java index d8235769c61..a642fc9ace3 100644 --- a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/jaas/ManagedUserBackingEngineFactory.java +++ b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/jaas/ManagedUserBackingEngineFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.karaf/src/main/java/org/openhab/core/karaf/internal/jaas/ManagedUserRealm.java b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/jaas/ManagedUserRealm.java index 0505f30b614..5c66a850167 100644 --- a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/jaas/ManagedUserRealm.java +++ b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/jaas/ManagedUserRealm.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.core/pom.xml b/bundles/org.openhab.core.model.core/pom.xml index c50d6ebad17..ce91eb736a5 100644 --- a/bundles/org.openhab.core.model.core/pom.xml +++ b/bundles/org.openhab.core.model.core/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.core diff --git a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/EventType.java b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/EventType.java index 7e3131e4e16..584c2ccc16f 100644 --- a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/EventType.java +++ b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/EventType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.core/src/main/java/org/openhab/core/model/core/ModelCoreConstants.java b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/ModelCoreConstants.java index 8bafc9a180a..1a7e1cd966b 100644 --- a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/ModelCoreConstants.java +++ b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/ModelCoreConstants.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.core/src/main/java/org/openhab/core/model/core/ModelParser.java b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/ModelParser.java index 2c5cada05f7..4adbab5882a 100644 --- a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/ModelParser.java +++ b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/ModelParser.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.core/src/main/java/org/openhab/core/model/core/ModelRepository.java b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/ModelRepository.java index 01f43228cdb..139629d050d 100644 --- a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/ModelRepository.java +++ b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/ModelRepository.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.core/src/main/java/org/openhab/core/model/core/ModelRepositoryChangeListener.java b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/ModelRepositoryChangeListener.java index 5537b51f9d7..ab6bc381301 100644 --- a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/ModelRepositoryChangeListener.java +++ b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/ModelRepositoryChangeListener.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.core/src/main/java/org/openhab/core/model/core/SafeEMF.java b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/SafeEMF.java index 47297822488..7bc170fa6b6 100644 --- a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/SafeEMF.java +++ b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/SafeEMF.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.core/src/main/java/org/openhab/core/model/core/internal/ModelCoreActivator.java b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/ModelCoreActivator.java index ad013d8c35f..5f3ff27c8d1 100644 --- a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/ModelCoreActivator.java +++ b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/ModelCoreActivator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.core/src/main/java/org/openhab/core/model/core/internal/ModelRepositoryImpl.java b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/ModelRepositoryImpl.java index 5a6eb142689..8c635a10cef 100644 --- a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/ModelRepositoryImpl.java +++ b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/ModelRepositoryImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -24,7 +24,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; -import java.util.stream.Collectors; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; @@ -99,7 +98,7 @@ public ModelRepositoryImpl(final @Reference SafeEMF safeEmf) { public boolean addOrRefreshModel(String name, final InputStream originalInputStream) { logger.info("Loading model '{}'", name); Resource resource = null; - byte[] bytes = null; + byte[] bytes; try (InputStream inputStream = originalInputStream) { bytes = inputStream.readAllBytes(); String validationResult = validateModel(name, new ByteArrayInputStream(bytes)); @@ -268,7 +267,7 @@ public void removeModelRepositoryChangeListener(ModelRepositoryChangeListener li .append(MessageFormat.format("[{0},{1}]: {2}\n", Integer.toString(diagnostic.getLine()), Integer.toString(diagnostic.getColumn()), diagnostic.getMessage())); } - if (criticalErrors.length() > 0) { + if (!criticalErrors.isEmpty()) { return criticalErrors.toString(); } @@ -281,7 +280,7 @@ public void removeModelRepositoryChangeListener(ModelRepositoryChangeListener li } if (!warnings.isEmpty()) { logger.info("Validation issues found in configuration model '{}', using it anyway:\n{}", name, - warnings.stream().collect(Collectors.joining("\n"))); + String.join("\n", warnings)); } } catch (NullPointerException e) { // see https://github.com/eclipse/smarthome/issues/3335 diff --git a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/SafeEMFImpl.java b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/SafeEMFImpl.java index 220798a3c31..87991ab5c06 100644 --- a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/SafeEMFImpl.java +++ b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/SafeEMFImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.core/src/main/java/org/openhab/core/model/core/internal/folder/FolderObserver.java b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/folder/FolderObserver.java index c9354918ae4..ff26c8f1ff0 100644 --- a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/folder/FolderObserver.java +++ b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/folder/FolderObserver.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.core/src/main/java/org/openhab/core/model/core/internal/util/MathUtils.java b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/util/MathUtils.java index 82413147445..12b0039e6ab 100644 --- a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/util/MathUtils.java +++ b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/util/MathUtils.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.core/src/main/java/org/openhab/core/model/core/valueconverter/ValueTypeToStringConverter.java b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/valueconverter/ValueTypeToStringConverter.java index ba2cb13c6ce..9c9133f7f80 100644 --- a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/valueconverter/ValueTypeToStringConverter.java +++ b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/valueconverter/ValueTypeToStringConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.core/src/test/java/org/openhab/core/model/core/internal/folder/FolderObserverTest.java b/bundles/org.openhab.core.model.core/src/test/java/org/openhab/core/model/core/internal/folder/FolderObserverTest.java index 75f45a445e1..c11b566257d 100644 --- a/bundles/org.openhab.core.model.core/src/test/java/org/openhab/core/model/core/internal/folder/FolderObserverTest.java +++ b/bundles/org.openhab.core.model.core/src/test/java/org/openhab/core/model/core/internal/folder/FolderObserverTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.item.ide/pom.xml b/bundles/org.openhab.core.model.item.ide/pom.xml index 05df5b8d7a8..b81113435d6 100644 --- a/bundles/org.openhab.core.model.item.ide/pom.xml +++ b/bundles/org.openhab.core.model.item.ide/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.item.ide diff --git a/bundles/org.openhab.core.model.item.ide/src/org/openhab/core/model/ide/ItemsIdeModule.xtend b/bundles/org.openhab.core.model.item.ide/src/org/openhab/core/model/ide/ItemsIdeModule.xtend index 64327964028..432db001cb6 100644 --- a/bundles/org.openhab.core.model.item.ide/src/org/openhab/core/model/ide/ItemsIdeModule.xtend +++ b/bundles/org.openhab.core.model.item.ide/src/org/openhab/core/model/ide/ItemsIdeModule.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.item.ide/src/org/openhab/core/model/ide/ItemsIdeSetup.xtend b/bundles/org.openhab.core.model.item.ide/src/org/openhab/core/model/ide/ItemsIdeSetup.xtend index 631114f89f0..4246f8c454f 100644 --- a/bundles/org.openhab.core.model.item.ide/src/org/openhab/core/model/ide/ItemsIdeSetup.xtend +++ b/bundles/org.openhab.core.model.item.ide/src/org/openhab/core/model/ide/ItemsIdeSetup.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.item.runtime/pom.xml b/bundles/org.openhab.core.model.item.runtime/pom.xml index 12474451ed0..f82f934f82b 100644 --- a/bundles/org.openhab.core.model.item.runtime/pom.xml +++ b/bundles/org.openhab.core.model.item.runtime/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.item.runtime diff --git a/bundles/org.openhab.core.model.item.runtime/src/org/openhab/core/model/item/runtime/internal/ItemRuntimeActivator.java b/bundles/org.openhab.core.model.item.runtime/src/org/openhab/core/model/item/runtime/internal/ItemRuntimeActivator.java index 581a9d5d266..e8182d38e47 100644 --- a/bundles/org.openhab.core.model.item.runtime/src/org/openhab/core/model/item/runtime/internal/ItemRuntimeActivator.java +++ b/bundles/org.openhab.core.model.item.runtime/src/org/openhab/core/model/item/runtime/internal/ItemRuntimeActivator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.item/pom.xml b/bundles/org.openhab.core.model.item/pom.xml index 29520867e2d..59379ead2b0 100644 --- a/bundles/org.openhab.core.model.item/pom.xml +++ b/bundles/org.openhab.core.model.item/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.item diff --git a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/GenerateItems.mwe2 b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/GenerateItems.mwe2 index b3cb9076926..73601221ca7 100644 --- a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/GenerateItems.mwe2 +++ b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/GenerateItems.mwe2 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.item/src/org/openhab/core/model/ItemsRuntimeModule.xtend b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/ItemsRuntimeModule.xtend index 129335845d4..6d4ed0fe6d9 100644 --- a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/ItemsRuntimeModule.xtend +++ b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/ItemsRuntimeModule.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.item/src/org/openhab/core/model/ItemsStandaloneSetup.xtend b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/ItemsStandaloneSetup.xtend index f42472e542f..216fefe0286 100644 --- a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/ItemsStandaloneSetup.xtend +++ b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/ItemsStandaloneSetup.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.item/src/org/openhab/core/model/formatting/ItemsFormatter.xtend b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/formatting/ItemsFormatter.xtend index a4d423548c0..52f1cb4a184 100644 --- a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/formatting/ItemsFormatter.xtend +++ b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/formatting/ItemsFormatter.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.item/src/org/openhab/core/model/generator/ItemsGenerator.xtend b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/generator/ItemsGenerator.xtend index 3e72b01aad6..e0eeb9439f0 100644 --- a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/generator/ItemsGenerator.xtend +++ b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/generator/ItemsGenerator.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.item/src/org/openhab/core/model/internal/valueconverter/ItemValueConverters.java b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/internal/valueconverter/ItemValueConverters.java index 9cb21713bb4..6a51d7a32ce 100644 --- a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/internal/valueconverter/ItemValueConverters.java +++ b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/internal/valueconverter/ItemValueConverters.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.item/src/org/openhab/core/model/item/BindingConfigParseException.java b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/item/BindingConfigParseException.java index 15ba621013c..671162b8775 100644 --- a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/item/BindingConfigParseException.java +++ b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/item/BindingConfigParseException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.item/src/org/openhab/core/model/item/BindingConfigReader.java b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/item/BindingConfigReader.java index 571a6b2f619..47461b21d4c 100644 --- a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/item/BindingConfigReader.java +++ b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/item/BindingConfigReader.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.item/src/org/openhab/core/model/item/internal/GenericItemProvider.java b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/item/internal/GenericItemProvider.java index a6a6cb67382..55383cf359f 100644 --- a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/item/internal/GenericItemProvider.java +++ b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/item/internal/GenericItemProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -255,6 +255,8 @@ private void processBindingConfigsFromModel(String modelName, EventType type) { label = label.substring(0, label.indexOf("[")).trim(); stateDescriptionFragments.put(modelItem.getName(), StateDescriptionFragmentBuilder.create().withPattern(format).build()); + } else { + stateDescriptionFragments.remove(modelItem.getName()); } activeItem.setLabel(label); activeItem.setCategory(modelItem.getIcon()); diff --git a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/item/internal/GenericMetadataProvider.java b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/item/internal/GenericMetadataProvider.java index 0cbbb88451a..34699058f62 100644 --- a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/item/internal/GenericMetadataProvider.java +++ b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/item/internal/GenericMetadataProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.item/src/org/openhab/core/model/scoping/ItemsScopeProvider.xtend b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/scoping/ItemsScopeProvider.xtend index 62ca9e726fa..2e354c5eb35 100644 --- a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/scoping/ItemsScopeProvider.xtend +++ b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/scoping/ItemsScopeProvider.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.item/src/org/openhab/core/model/serializer/ItemsSemanticSequencer.xtend b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/serializer/ItemsSemanticSequencer.xtend index 78bcf3e022e..bcc20d0e1dc 100644 --- a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/serializer/ItemsSemanticSequencer.xtend +++ b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/serializer/ItemsSemanticSequencer.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.item/src/org/openhab/core/model/serializer/ItemsSyntacticSequencer.xtend b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/serializer/ItemsSyntacticSequencer.xtend index de1d50b827f..d8ee6482c46 100644 --- a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/serializer/ItemsSyntacticSequencer.xtend +++ b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/serializer/ItemsSyntacticSequencer.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.item/src/org/openhab/core/model/validation/ItemsValidator.xtend b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/validation/ItemsValidator.xtend index 7755870f8a2..4e29d2e884b 100644 --- a/bundles/org.openhab.core.model.item/src/org/openhab/core/model/validation/ItemsValidator.xtend +++ b/bundles/org.openhab.core.model.item/src/org/openhab/core/model/validation/ItemsValidator.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.lazygen/pom.xml b/bundles/org.openhab.core.model.lazygen/pom.xml index 5f597e208bd..d6880a8fca5 100644 --- a/bundles/org.openhab.core.model.lazygen/pom.xml +++ b/bundles/org.openhab.core.model.lazygen/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.lazygen diff --git a/bundles/org.openhab.core.model.lazygen/src/main/java/org/openhab/core/model/lazygen/GlobalResourceSet.java b/bundles/org.openhab.core.model.lazygen/src/main/java/org/openhab/core/model/lazygen/GlobalResourceSet.java index 14f191f3d19..729f13df4b1 100644 --- a/bundles/org.openhab.core.model.lazygen/src/main/java/org/openhab/core/model/lazygen/GlobalResourceSet.java +++ b/bundles/org.openhab.core.model.lazygen/src/main/java/org/openhab/core/model/lazygen/GlobalResourceSet.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.lazygen/src/main/java/org/openhab/core/model/lazygen/LazyGenerator.java b/bundles/org.openhab.core.model.lazygen/src/main/java/org/openhab/core/model/lazygen/LazyGenerator.java index 725d5a64d48..dd292bbc8fe 100644 --- a/bundles/org.openhab.core.model.lazygen/src/main/java/org/openhab/core/model/lazygen/LazyGenerator.java +++ b/bundles/org.openhab.core.model.lazygen/src/main/java/org/openhab/core/model/lazygen/LazyGenerator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.lazygen/src/main/java/org/openhab/core/model/lazygen/LazyLanguageConfig.java b/bundles/org.openhab.core.model.lazygen/src/main/java/org/openhab/core/model/lazygen/LazyLanguageConfig.java index 411c1954655..90493da3443 100644 --- a/bundles/org.openhab.core.model.lazygen/src/main/java/org/openhab/core/model/lazygen/LazyLanguageConfig.java +++ b/bundles/org.openhab.core.model.lazygen/src/main/java/org/openhab/core/model/lazygen/LazyLanguageConfig.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.lazygen/src/main/java/org/openhab/core/model/lazygen/LazyStandaloneSetup.java b/bundles/org.openhab.core.model.lazygen/src/main/java/org/openhab/core/model/lazygen/LazyStandaloneSetup.java index 5052a4b5bff..4a5195f5dde 100644 --- a/bundles/org.openhab.core.model.lazygen/src/main/java/org/openhab/core/model/lazygen/LazyStandaloneSetup.java +++ b/bundles/org.openhab.core.model.lazygen/src/main/java/org/openhab/core/model/lazygen/LazyStandaloneSetup.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.lsp/pom.xml b/bundles/org.openhab.core.model.lsp/pom.xml index 0b04b3686c6..494d16fe2f3 100644 --- a/bundles/org.openhab.core.model.lsp/pom.xml +++ b/bundles/org.openhab.core.model.lsp/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.lsp diff --git a/bundles/org.openhab.core.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/MappingUriExtensions.java b/bundles/org.openhab.core.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/MappingUriExtensions.java index d4456680ae7..053b4581d1e 100644 --- a/bundles/org.openhab.core.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/MappingUriExtensions.java +++ b/bundles/org.openhab.core.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/MappingUriExtensions.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/ModelServer.java b/bundles/org.openhab.core.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/ModelServer.java index 7880c12c6ff..57e0b596175 100644 --- a/bundles/org.openhab.core.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/ModelServer.java +++ b/bundles/org.openhab.core.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/ModelServer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/RegistryProvider.java b/bundles/org.openhab.core.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/RegistryProvider.java index f07ca698e0d..bfb6607ff5a 100644 --- a/bundles/org.openhab.core.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/RegistryProvider.java +++ b/bundles/org.openhab.core.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/RegistryProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/RuntimeServerModule.java b/bundles/org.openhab.core.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/RuntimeServerModule.java index 67eae8ba4f7..ae732592d77 100644 --- a/bundles/org.openhab.core.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/RuntimeServerModule.java +++ b/bundles/org.openhab.core.model.lsp/src/main/java/org/openhab/core/model/lsp/internal/RuntimeServerModule.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.lsp/src/test/java/org/openhab/core/model/lsp/internal/MappingUriExtensionsTest.java b/bundles/org.openhab.core.model.lsp/src/test/java/org/openhab/core/model/lsp/internal/MappingUriExtensionsTest.java index 61c415a3334..86eae148dd1 100644 --- a/bundles/org.openhab.core.model.lsp/src/test/java/org/openhab/core/model/lsp/internal/MappingUriExtensionsTest.java +++ b/bundles/org.openhab.core.model.lsp/src/test/java/org/openhab/core/model/lsp/internal/MappingUriExtensionsTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.persistence.ide/pom.xml b/bundles/org.openhab.core.model.persistence.ide/pom.xml index 369f7137ecd..6f09055154e 100644 --- a/bundles/org.openhab.core.model.persistence.ide/pom.xml +++ b/bundles/org.openhab.core.model.persistence.ide/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.persistence.ide diff --git a/bundles/org.openhab.core.model.persistence.ide/src/org/openhab/core/model/persistence/ide/PersistenceIdeModule.xtend b/bundles/org.openhab.core.model.persistence.ide/src/org/openhab/core/model/persistence/ide/PersistenceIdeModule.xtend index a916c0e7d25..6c94f85437f 100644 --- a/bundles/org.openhab.core.model.persistence.ide/src/org/openhab/core/model/persistence/ide/PersistenceIdeModule.xtend +++ b/bundles/org.openhab.core.model.persistence.ide/src/org/openhab/core/model/persistence/ide/PersistenceIdeModule.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.persistence.ide/src/org/openhab/core/model/persistence/ide/PersistenceIdeSetup.xtend b/bundles/org.openhab.core.model.persistence.ide/src/org/openhab/core/model/persistence/ide/PersistenceIdeSetup.xtend index 1943c4f2b2d..92a0b811d2e 100644 --- a/bundles/org.openhab.core.model.persistence.ide/src/org/openhab/core/model/persistence/ide/PersistenceIdeSetup.xtend +++ b/bundles/org.openhab.core.model.persistence.ide/src/org/openhab/core/model/persistence/ide/PersistenceIdeSetup.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.persistence.runtime/pom.xml b/bundles/org.openhab.core.model.persistence.runtime/pom.xml index c3ee9f7399f..185bd0df985 100644 --- a/bundles/org.openhab.core.model.persistence.runtime/pom.xml +++ b/bundles/org.openhab.core.model.persistence.runtime/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.persistence.runtime diff --git a/bundles/org.openhab.core.model.persistence.runtime/src/org/openhab/core/model/persistence/runtime/internal/PersistenceRuntimeActivator.java b/bundles/org.openhab.core.model.persistence.runtime/src/org/openhab/core/model/persistence/runtime/internal/PersistenceRuntimeActivator.java index abfff3c537f..52b31324233 100644 --- a/bundles/org.openhab.core.model.persistence.runtime/src/org/openhab/core/model/persistence/runtime/internal/PersistenceRuntimeActivator.java +++ b/bundles/org.openhab.core.model.persistence.runtime/src/org/openhab/core/model/persistence/runtime/internal/PersistenceRuntimeActivator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.persistence/pom.xml b/bundles/org.openhab.core.model.persistence/pom.xml index a06b5b2d206..20ed6956f4a 100644 --- a/bundles/org.openhab.core.model.persistence/pom.xml +++ b/bundles/org.openhab.core.model.persistence/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.persistence diff --git a/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/GeneratePersistence.mwe2 b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/GeneratePersistence.mwe2 index 4cba553e9f5..3dad59d4a0b 100644 --- a/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/GeneratePersistence.mwe2 +++ b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/GeneratePersistence.mwe2 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.persistence/src/org/openhab/core/model/persistence/PersistenceRuntimeModule.xtend b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/PersistenceRuntimeModule.xtend index 1de2e307d5f..eb9caa8d60a 100644 --- a/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/PersistenceRuntimeModule.xtend +++ b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/PersistenceRuntimeModule.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.persistence/src/org/openhab/core/model/persistence/PersistenceStandaloneSetup.xtend b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/PersistenceStandaloneSetup.xtend index 0d3192444c5..9ee131992b9 100644 --- a/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/PersistenceStandaloneSetup.xtend +++ b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/PersistenceStandaloneSetup.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.persistence/src/org/openhab/core/model/persistence/formatting/PersistenceFormatter.xtend b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/formatting/PersistenceFormatter.xtend index 6eeccee93fe..ec054b83a96 100644 --- a/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/formatting/PersistenceFormatter.xtend +++ b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/formatting/PersistenceFormatter.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.persistence/src/org/openhab/core/model/persistence/generator/PersistenceGenerator.xtend b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/generator/PersistenceGenerator.xtend index 36f9eec3d0c..1e03c00ff81 100644 --- a/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/generator/PersistenceGenerator.xtend +++ b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/generator/PersistenceGenerator.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.persistence/src/org/openhab/core/model/persistence/internal/PersistenceModelManager.java b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/internal/PersistenceModelManager.java index aa7688a14e7..60fb35d992f 100644 --- a/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/internal/PersistenceModelManager.java +++ b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/internal/PersistenceModelManager.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.persistence/src/org/openhab/core/model/persistence/scoping/GlobalStrategies.java b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/scoping/GlobalStrategies.java index 401feb97b06..ec1f3af6302 100644 --- a/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/scoping/GlobalStrategies.java +++ b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/scoping/GlobalStrategies.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,26 +27,26 @@ public class GlobalStrategies { @Override public String getName() { return "everyUpdate"; - }; + } }; public static final Strategy CHANGE = new StrategyImpl() { @Override public String getName() { return "everyChange"; - }; + } }; public static final Strategy RESTORE = new StrategyImpl() { @Override public String getName() { return "restoreOnStartup"; - }; + } }; public static final Strategy FORECAST = new StrategyImpl() { @Override public String getName() { return "forecast"; - }; + } }; } diff --git a/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/scoping/PersistenceGlobalScopeProvider.java b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/scoping/PersistenceGlobalScopeProvider.java index d070495fa14..eb72f9c318f 100644 --- a/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/scoping/PersistenceGlobalScopeProvider.java +++ b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/scoping/PersistenceGlobalScopeProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.persistence/src/org/openhab/core/model/persistence/scoping/PersistenceScopeProvider.xtend b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/scoping/PersistenceScopeProvider.xtend index 66d43efc0bd..c2d541a4b06 100644 --- a/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/scoping/PersistenceScopeProvider.xtend +++ b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/scoping/PersistenceScopeProvider.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.persistence/src/org/openhab/core/model/persistence/serializer/PersistenceSemanticSequencer.xtend b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/serializer/PersistenceSemanticSequencer.xtend index ef347889dbc..560a9ac44e3 100644 --- a/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/serializer/PersistenceSemanticSequencer.xtend +++ b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/serializer/PersistenceSemanticSequencer.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.persistence/src/org/openhab/core/model/persistence/serializer/PersistenceSyntacticSequencer.xtend b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/serializer/PersistenceSyntacticSequencer.xtend index 80898cf782e..d95afa23573 100644 --- a/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/serializer/PersistenceSyntacticSequencer.xtend +++ b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/serializer/PersistenceSyntacticSequencer.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.persistence/src/org/openhab/core/model/persistence/validation/PersistenceValidator.xtend b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/validation/PersistenceValidator.xtend index bf160858649..af3841be2b8 100644 --- a/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/validation/PersistenceValidator.xtend +++ b/bundles/org.openhab.core.model.persistence/src/org/openhab/core/model/persistence/validation/PersistenceValidator.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule.ide/pom.xml b/bundles/org.openhab.core.model.rule.ide/pom.xml index 9a5340242f7..c4bc893e5dd 100644 --- a/bundles/org.openhab.core.model.rule.ide/pom.xml +++ b/bundles/org.openhab.core.model.rule.ide/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.rule.ide diff --git a/bundles/org.openhab.core.model.rule.ide/src/org/openhab/core/model/rule/ide/RulesIdeModule.xtend b/bundles/org.openhab.core.model.rule.ide/src/org/openhab/core/model/rule/ide/RulesIdeModule.xtend index c446a160c24..28b8a2a6315 100644 --- a/bundles/org.openhab.core.model.rule.ide/src/org/openhab/core/model/rule/ide/RulesIdeModule.xtend +++ b/bundles/org.openhab.core.model.rule.ide/src/org/openhab/core/model/rule/ide/RulesIdeModule.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule.ide/src/org/openhab/core/model/rule/ide/RulesIdeSetup.xtend b/bundles/org.openhab.core.model.rule.ide/src/org/openhab/core/model/rule/ide/RulesIdeSetup.xtend index bc477163368..4a27ae3d26e 100644 --- a/bundles/org.openhab.core.model.rule.ide/src/org/openhab/core/model/rule/ide/RulesIdeSetup.xtend +++ b/bundles/org.openhab.core.model.rule.ide/src/org/openhab/core/model/rule/ide/RulesIdeSetup.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule.runtime/pom.xml b/bundles/org.openhab.core.model.rule.runtime/pom.xml index c50f352a685..ec5fb5bec79 100644 --- a/bundles/org.openhab.core.model.rule.runtime/pom.xml +++ b/bundles/org.openhab.core.model.rule.runtime/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.rule.runtime diff --git a/bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/DSLRuleProvider.java b/bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/DSLRuleProvider.java index 3e7c493ab4b..da92c9fe0ad 100644 --- a/bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/DSLRuleProvider.java +++ b/bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/DSLRuleProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/RuleContextHelper.java b/bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/RuleContextHelper.java index b7b01cc2cf1..aa170a2b06d 100644 --- a/bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/RuleContextHelper.java +++ b/bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/RuleContextHelper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/RuleEvaluationContext.java b/bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/RuleEvaluationContext.java index 121795b635c..29689b095e0 100644 --- a/bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/RuleEvaluationContext.java +++ b/bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/RuleEvaluationContext.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/RuleRuntimeActivator.java b/bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/RuleRuntimeActivator.java index 16d86d2a877..79b38efd016 100644 --- a/bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/RuleRuntimeActivator.java +++ b/bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/RuleRuntimeActivator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule/pom.xml b/bundles/org.openhab.core.model.rule/pom.xml index 1ed15469225..4beb1f8d27b 100644 --- a/bundles/org.openhab.core.model.rule/pom.xml +++ b/bundles/org.openhab.core.model.rule/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.rule diff --git a/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/GenerateRules.mwe2 b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/GenerateRules.mwe2 index eb0e371aa51..eafe516deef 100644 --- a/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/GenerateRules.mwe2 +++ b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/GenerateRules.mwe2 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule/src/org/openhab/core/model/rule/RulesRuntimeModule.xtend b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/RulesRuntimeModule.xtend index ed027f9b180..06fb454ac9d 100644 --- a/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/RulesRuntimeModule.xtend +++ b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/RulesRuntimeModule.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule/src/org/openhab/core/model/rule/RulesStandaloneSetup.xtend b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/RulesStandaloneSetup.xtend index fc716c73b25..fc7eab96bf5 100644 --- a/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/RulesStandaloneSetup.xtend +++ b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/RulesStandaloneSetup.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule/src/org/openhab/core/model/rule/formatting/RulesFormatter.xtend b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/formatting/RulesFormatter.xtend index 875940c6c21..4677847a442 100644 --- a/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/formatting/RulesFormatter.xtend +++ b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/formatting/RulesFormatter.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule/src/org/openhab/core/model/rule/jvmmodel/RulesJvmModelInferrer.xtend b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/jvmmodel/RulesJvmModelInferrer.xtend index 2c0d86668ab..94a847dd0eb 100644 --- a/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/jvmmodel/RulesJvmModelInferrer.xtend +++ b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/jvmmodel/RulesJvmModelInferrer.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule/src/org/openhab/core/model/rule/jvmmodel/RulesRefresher.java b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/jvmmodel/RulesRefresher.java index 7296cea8b68..c6d76735692 100644 --- a/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/jvmmodel/RulesRefresher.java +++ b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/jvmmodel/RulesRefresher.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule/src/org/openhab/core/model/rule/scoping/RulesClassCache.java b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/scoping/RulesClassCache.java index fc6f73893fc..ff8c6b29f97 100644 --- a/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/scoping/RulesClassCache.java +++ b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/scoping/RulesClassCache.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule/src/org/openhab/core/model/rule/scoping/RulesClassFinder.java b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/scoping/RulesClassFinder.java index b545a334751..12826f65205 100644 --- a/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/scoping/RulesClassFinder.java +++ b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/scoping/RulesClassFinder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule/src/org/openhab/core/model/rule/scoping/RulesImplicitlyImportedTypes.java b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/scoping/RulesImplicitlyImportedTypes.java index 210de177e91..2cc579f2c1e 100644 --- a/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/scoping/RulesImplicitlyImportedTypes.java +++ b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/scoping/RulesImplicitlyImportedTypes.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule/src/org/openhab/core/model/rule/scoping/RulesJavaReflectAccess.java b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/scoping/RulesJavaReflectAccess.java index e0fd76d432a..40dcf9551a1 100644 --- a/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/scoping/RulesJavaReflectAccess.java +++ b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/scoping/RulesJavaReflectAccess.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule/src/org/openhab/core/model/rule/scoping/RulesScopeProvider.xtend b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/scoping/RulesScopeProvider.xtend index 168d3409d04..ad9823a7087 100644 --- a/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/scoping/RulesScopeProvider.xtend +++ b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/scoping/RulesScopeProvider.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule/src/org/openhab/core/model/rule/serializer/RulesSemanticSequencer.xtend b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/serializer/RulesSemanticSequencer.xtend index 6b1a942426d..e260cb05de1 100644 --- a/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/serializer/RulesSemanticSequencer.xtend +++ b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/serializer/RulesSemanticSequencer.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule/src/org/openhab/core/model/rule/serializer/RulesSyntacticSequencer.xtend b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/serializer/RulesSyntacticSequencer.xtend index 17df6c395b8..3a02b2e2a23 100644 --- a/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/serializer/RulesSyntacticSequencer.xtend +++ b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/serializer/RulesSyntacticSequencer.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.rule/src/org/openhab/core/model/rule/validation/RulesValidator.xtend b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/validation/RulesValidator.xtend index 57e13364c25..7f6af05461a 100644 --- a/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/validation/RulesValidator.xtend +++ b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/validation/RulesValidator.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script.ide/pom.xml b/bundles/org.openhab.core.model.script.ide/pom.xml index f8f46e5b217..e16edbdfd90 100644 --- a/bundles/org.openhab.core.model.script.ide/pom.xml +++ b/bundles/org.openhab.core.model.script.ide/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.script.ide diff --git a/bundles/org.openhab.core.model.script.ide/src/org/openhab/core/model/script/ide/ScriptIdeModule.xtend b/bundles/org.openhab.core.model.script.ide/src/org/openhab/core/model/script/ide/ScriptIdeModule.xtend index 809a21d7c7a..6f78df54b92 100644 --- a/bundles/org.openhab.core.model.script.ide/src/org/openhab/core/model/script/ide/ScriptIdeModule.xtend +++ b/bundles/org.openhab.core.model.script.ide/src/org/openhab/core/model/script/ide/ScriptIdeModule.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script.ide/src/org/openhab/core/model/script/ide/ScriptIdeSetup.xtend b/bundles/org.openhab.core.model.script.ide/src/org/openhab/core/model/script/ide/ScriptIdeSetup.xtend index 0fd736be28f..350b27e59a0 100644 --- a/bundles/org.openhab.core.model.script.ide/src/org/openhab/core/model/script/ide/ScriptIdeSetup.xtend +++ b/bundles/org.openhab.core.model.script.ide/src/org/openhab/core/model/script/ide/ScriptIdeSetup.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script.runtime/pom.xml b/bundles/org.openhab.core.model.script.runtime/pom.xml index 1536cca6f37..76a0ca195ef 100644 --- a/bundles/org.openhab.core.model.script.runtime/pom.xml +++ b/bundles/org.openhab.core.model.script.runtime/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.script.runtime diff --git a/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/DSLScriptContextProvider.java b/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/DSLScriptContextProvider.java index f09d8de281e..f87284304ce 100644 --- a/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/DSLScriptContextProvider.java +++ b/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/DSLScriptContextProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -30,7 +30,7 @@ public interface DSLScriptContextProvider { /** * Identifier for scripts that are created from a DSL rule file */ - static final String CONTEXT_IDENTIFIER = "// context: "; + String CONTEXT_IDENTIFIER = "// context: "; /** * Returns the evaluation context, i.e. the current state of the variables of the rule file. diff --git a/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/ScriptRuntime.java b/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/ScriptRuntime.java index 5b3f3ba5080..2e4df62c661 100644 --- a/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/ScriptRuntime.java +++ b/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/ScriptRuntime.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/DSLScriptEngine.java b/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/DSLScriptEngine.java index 7ae6cc6c51f..88500880281 100644 --- a/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/DSLScriptEngine.java +++ b/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/DSLScriptEngine.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/DSLScriptEngineFactory.java b/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/DSLScriptEngineFactory.java index aa0ed8f951d..745d8d39822 100644 --- a/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/DSLScriptEngineFactory.java +++ b/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/DSLScriptEngineFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/ScriptEngineImpl.java b/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/ScriptEngineImpl.java index 01c2be9843e..cae59cd29fc 100644 --- a/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/ScriptEngineImpl.java +++ b/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/ScriptEngineImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/ScriptImpl.java b/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/ScriptImpl.java index 985ed287af0..544c845b411 100644 --- a/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/ScriptImpl.java +++ b/bundles/org.openhab.core.model.script.runtime/src/org/openhab/core/model/script/runtime/internal/engine/ScriptImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/pom.xml b/bundles/org.openhab.core.model.script/pom.xml index 225e2d63f02..92736aaa273 100644 --- a/bundles/org.openhab.core.model.script/pom.xml +++ b/bundles/org.openhab.core.model.script/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.script diff --git a/bundles/org.openhab.core.model.script/src.moved/test/java/org/openhab/core/model/script/actions/SemanticsTest.java b/bundles/org.openhab.core.model.script/src.moved/test/java/org/openhab/core/model/script/actions/SemanticsTest.java index be07ec03be5..934ba31a2aa 100644 --- a/bundles/org.openhab.core.model.script/src.moved/test/java/org/openhab/core/model/script/actions/SemanticsTest.java +++ b/bundles/org.openhab.core.model.script/src.moved/test/java/org/openhab/core/model/script/actions/SemanticsTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src.moved/test/java/org/openhab/core/model/script/lib/NumberExtensionsTest.java b/bundles/org.openhab.core.model.script/src.moved/test/java/org/openhab/core/model/script/lib/NumberExtensionsTest.java index 1ffeb412715..56fd43ede2c 100644 --- a/bundles/org.openhab.core.model.script/src.moved/test/java/org/openhab/core/model/script/lib/NumberExtensionsTest.java +++ b/bundles/org.openhab.core.model.script/src.moved/test/java/org/openhab/core/model/script/lib/NumberExtensionsTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -253,7 +253,7 @@ public void testOperatorPlus() { BigDecimal result = NumberExtensions.operator_plus(x, y); assertNotNull(result); - assertEquals(result, new BigDecimal(9)); + assertEquals(new BigDecimal(9), result); } /** @@ -267,7 +267,7 @@ public void testOperatorPlusNullLeft() { BigDecimal result = NumberExtensions.operator_plus(x, y); assertNotNull(result); - assertEquals(result, new BigDecimal(5)); + assertEquals(new BigDecimal(5), result); } /** @@ -281,7 +281,7 @@ public void testOperatorPlusNullRight() { BigDecimal result = NumberExtensions.operator_plus(x, y); assertNotNull(result); - assertEquals(result, new BigDecimal(10)); + assertEquals(new BigDecimal(10), result); } /** @@ -294,7 +294,7 @@ public void testOperatorMinusNumber() { BigDecimal result = NumberExtensions.operator_minus(x); assertNotNull(result); - assertEquals(result, new BigDecimal(-2)); + assertEquals(new BigDecimal(-2), result); } /** @@ -320,7 +320,7 @@ public void testOperatorMinusNumberNumber() { BigDecimal result = NumberExtensions.operator_minus(x, y); assertNotNull(result); - assertEquals(result, new BigDecimal(10 - 100)); + assertEquals(new BigDecimal(10 - 100), result); } /** @@ -334,7 +334,7 @@ public void testOperatorMinusNullNumber() { BigDecimal result = NumberExtensions.operator_minus(x, y); assertNotNull(result); - assertEquals(result, new BigDecimal(-100)); + assertEquals(new BigDecimal(-100), result); } /** @@ -348,7 +348,7 @@ public void testOperatorMinusNumberNull() { BigDecimal result = NumberExtensions.operator_minus(x, y); assertNotNull(result); - assertEquals(result, new BigDecimal(10)); + assertEquals(new BigDecimal(10), result); } /** @@ -362,7 +362,7 @@ public void testOperatorMultiply() { BigDecimal result = NumberExtensions.operator_multiply(x, y); assertNotNull(result); - assertEquals(result, new BigDecimal(20 * 30)); + assertEquals(new BigDecimal(20 * 30), result); } /** @@ -376,7 +376,7 @@ public void testOperatorMultiplyNullLeft() { BigDecimal result = NumberExtensions.operator_multiply(x, y); assertNotNull(result); - assertEquals(result, new BigDecimal(0)); + assertEquals(new BigDecimal(0), result); } /** @@ -390,7 +390,7 @@ public void testOperatorMultiplyNullRight() { BigDecimal result = NumberExtensions.operator_multiply(x, y); assertNotNull(result); - assertEquals(result, new BigDecimal(0)); + assertEquals(new BigDecimal(0), result); } /** diff --git a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/GenerateScript.mwe2 b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/GenerateScript.mwe2 index 5a67a63273f..3722b2c93e9 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/GenerateScript.mwe2 +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/GenerateScript.mwe2 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/OptimizingFeatureScopeTrackerProvider2.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/OptimizingFeatureScopeTrackerProvider2.java index 9aadbd8cb7e..5cdda94958f 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/OptimizingFeatureScopeTrackerProvider2.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/OptimizingFeatureScopeTrackerProvider2.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/ScriptRuntimeModule.xtend b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/ScriptRuntimeModule.xtend index f54f288ca57..d738b0816b8 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/ScriptRuntimeModule.xtend +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/ScriptRuntimeModule.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/ScriptServiceUtil.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/ScriptServiceUtil.java index 0cc758445f8..70e604ececa 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/ScriptServiceUtil.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/ScriptServiceUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/ScriptStandaloneSetup.xtend b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/ScriptStandaloneSetup.xtend index 6cf125f1e42..8d7556194af 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/ScriptStandaloneSetup.xtend +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/ScriptStandaloneSetup.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/ServiceModule.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/ServiceModule.java index 4ff62e4d98b..e45649bc72b 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/ServiceModule.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/ServiceModule.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/actions/Audio.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Audio.java index 1f8fb6adfd1..cb88360079f 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Audio.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Audio.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/actions/BusEvent.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/BusEvent.java index bf07cd620d2..c44e7c836bf 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/BusEvent.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/BusEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/actions/CoreUtil.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/CoreUtil.java index 5b35a55387c..50fb23fed5d 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/CoreUtil.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/CoreUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,6 +36,14 @@ public static int hsbTosRgb(HSBType hsb) { return ColorUtil.hsbTosRgb(hsb); } + public static int[] hsbToRgbw(HSBType hsb) { + return ColorUtil.hsbToRgbw(hsb); + } + + public static PercentType[] hsbToRgbwPercent(HSBType hsb) { + return ColorUtil.hsbToRgbwPercent(hsb); + } + public static double[] hsbToXY(HSBType hsb) { return ColorUtil.hsbToXY(hsb); } diff --git a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Ephemeris.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Ephemeris.java index 55065720946..0e3a0b290f0 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Ephemeris.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Ephemeris.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/actions/Exec.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Exec.java index b83aa640207..efed4a2201a 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Exec.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Exec.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +34,6 @@ public class Exec { * * @param commandLine * the command line to execute - * @see http://www.peterfriese.de/running-applescript-from-java/ */ public static void executeCommandLine(String... commandLine) { ExecUtil.executeCommandLine(commandLine); diff --git a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/HTTP.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/HTTP.java index 6c589d241b7..a48df46e7f9 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/HTTP.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/HTTP.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/actions/Log.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Log.java index fb44dec1a9f..b51a5fbc912 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Log.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Log.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/actions/Ping.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Ping.java index ad90e97ec3b..36829f50072 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Ping.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Ping.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/actions/ScriptExecution.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/ScriptExecution.java index 10f022d1f84..fa002c7c0ca 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/ScriptExecution.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/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.model.script/src/org/openhab/core/model/script/actions/Semantics.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Semantics.java index 08e64f5f8f5..0915535b789 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Semantics.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Semantics.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/actions/Things.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Things.java index 642d6f2946a..ba4abd36931 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Things.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Things.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/actions/Timer.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Timer.java index 22847146a9b..99d93ef4b9d 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Timer.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/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.model.script/src/org/openhab/core/model/script/actions/Transformation.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Transformation.java index c87356e1f26..795044df765 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Transformation.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Transformation.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/actions/TransformationException.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/TransformationException.java index 6b2f427f14f..833100ecc18 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/TransformationException.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/TransformationException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/actions/Voice.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Voice.java index 9c5647ac784..30df09855aa 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Voice.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/actions/Voice.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 @@ public static void startDialog(@ParamDoc(name = "keyword spotting service") @Nul } if (locale != null) { String[] split = locale.split("-"); - Locale loc = null; + Locale loc; if (split.length == 2) { loc = new Locale(split[0], split[1]); } else { @@ -450,7 +450,7 @@ public static void listenAndAnswer(@ParamDoc(name = "speech-to-text service") @N dialogContextBuilder.withListeningItem(listeningItem); } if (locale != null) { - Locale loc = null; + Locale loc; String[] split = locale.split("-"); if (split.length == 2) { loc = new Locale(split[0], split[1]); diff --git a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/IActionServiceProvider.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/IActionServiceProvider.java index 9f7c4ce2b69..af944df983b 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/IActionServiceProvider.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/IActionServiceProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/engine/IThingActionsProvider.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/IThingActionsProvider.java index 6c3afc8957c..a3967b6ff74 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/IThingActionsProvider.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/IThingActionsProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/engine/Script.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/Script.java index 7f821da605c..2a04267cadc 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/Script.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/Script.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -22,7 +22,7 @@ @SuppressWarnings("restriction") public interface Script { - static final String SCRIPT_FILEEXT = "script"; + String SCRIPT_FILEEXT = "script"; /** * Executes the script instance and returns the execution result diff --git a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/ScriptEngine.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/ScriptEngine.java index cf4c1ed24bb..fdc9a069e08 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/ScriptEngine.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/ScriptEngine.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/engine/ScriptError.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/ScriptError.java index b9a1bf675e2..e7bbd64f563 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/ScriptError.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/ScriptError.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/engine/ScriptException.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/ScriptException.java index 40090adfae9..18fbbd1befe 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/ScriptException.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/ScriptException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -74,8 +74,6 @@ private ScriptException(final Throwable cause, final String scriptText, final Sc /** * Creates a ScriptException with one Error. - * - * @param errors */ private ScriptException(final String scriptText, final ScriptError error) { super(error.getMessage()); // ? @@ -134,7 +132,7 @@ public String getMessage() { int i = 1; for (ScriptError e : getErrors()) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append('\n'); } sb.append(" "); diff --git a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/ScriptExecutionException.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/ScriptExecutionException.java index abef73dbc2d..70f415408ad 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/ScriptExecutionException.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/ScriptExecutionException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/engine/ScriptParsingException.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/ScriptParsingException.java index 758f77927c3..e543b36695c 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/ScriptParsingException.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/ScriptParsingException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/engine/action/ActionDoc.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/action/ActionDoc.java index 88740c737bc..f3ed7f9cf22 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/action/ActionDoc.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/action/ActionDoc.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/engine/action/ActionService.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/action/ActionService.java index 519da7c9671..71feb8e9606 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/action/ActionService.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/action/ActionService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/engine/action/ParamDoc.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/action/ParamDoc.java index fd0af3e1dc8..94f1ccb5b06 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/action/ParamDoc.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/engine/action/ParamDoc.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/extension/ScriptEngineConsoleCommandExtension.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/extension/ScriptEngineConsoleCommandExtension.java index 361c6a69047..c9c660c42fd 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/extension/ScriptEngineConsoleCommandExtension.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/extension/ScriptEngineConsoleCommandExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/formatting/ScriptFormatter.xtend b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/formatting/ScriptFormatter.xtend index 377bf6b9509..644b4032251 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/formatting/ScriptFormatter.xtend +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/formatting/ScriptFormatter.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/internal/RuleHumanLanguageInterpreter.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/RuleHumanLanguageInterpreter.java index 4c8f42e5146..b9044679342 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/RuleHumanLanguageInterpreter.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/RuleHumanLanguageInterpreter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/internal/ScriptEncodingProvider.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/ScriptEncodingProvider.java index f36b2ee1779..c280ec5e2a9 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/ScriptEncodingProvider.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/ScriptEncodingProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/internal/engine/ServiceTrackerActionServiceProvider.xtend b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/ServiceTrackerActionServiceProvider.xtend index a96f7905b7e..6fa6d70c920 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/ServiceTrackerActionServiceProvider.xtend +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/ServiceTrackerActionServiceProvider.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/internal/engine/ServiceTrackerThingActionsProvider.xtend b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/ServiceTrackerThingActionsProvider.xtend index 1e399b3414f..747b92568bb 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/ServiceTrackerThingActionsProvider.xtend +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/ServiceTrackerThingActionsProvider.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/internal/engine/action/AudioActionService.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/AudioActionService.java index e27410ccb57..f29f4498fe2 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/AudioActionService.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/AudioActionService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/internal/engine/action/EphemerisActionService.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/EphemerisActionService.java index 7f6d0075548..fcac12b0d92 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/EphemerisActionService.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/EphemerisActionService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/internal/engine/action/PersistenceActionService.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/PersistenceActionService.java index 8ef9c44c0f6..84efa9be000 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/PersistenceActionService.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/PersistenceActionService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/internal/engine/action/ScriptExecutionActionService.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/ScriptExecutionActionService.java index 7d36d1a244c..b04aee62f19 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/ScriptExecutionActionService.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/ScriptExecutionActionService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/internal/engine/action/SemanticsActionService.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/SemanticsActionService.java index 3ca16c5f5ad..c7119a9025e 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/SemanticsActionService.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/SemanticsActionService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/internal/engine/action/ThingActionService.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/ThingActionService.java index b127c2b425f..e318aa97bf5 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/ThingActionService.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/ThingActionService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/internal/engine/action/VoiceActionService.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/VoiceActionService.java index 075b9457a02..610943b77ff 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/VoiceActionService.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/internal/engine/action/VoiceActionService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/interpreter/ScriptInterpreter.xtend b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/interpreter/ScriptInterpreter.xtend index 06fa190ed4d..a2ed1d685ef 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/interpreter/ScriptInterpreter.xtend +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/interpreter/ScriptInterpreter.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/jvmmodel/ScriptItemRefresher.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/jvmmodel/ScriptItemRefresher.java index 29f80461501..727a929d990 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/jvmmodel/ScriptItemRefresher.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/jvmmodel/ScriptItemRefresher.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/jvmmodel/ScriptJvmModelInferrer.xtend b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/jvmmodel/ScriptJvmModelInferrer.xtend index 98d490c2dcc..9282ae3a513 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/jvmmodel/ScriptJvmModelInferrer.xtend +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/jvmmodel/ScriptJvmModelInferrer.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/jvmmodel/ScriptTypeComputer.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/jvmmodel/ScriptTypeComputer.java index 1da6596e0a0..bfc986a9947 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/jvmmodel/ScriptTypeComputer.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/jvmmodel/ScriptTypeComputer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/lib/NumberExtensions.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/lib/NumberExtensions.java index 4b05df4e84b..e8619c54039 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/lib/NumberExtensions.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/lib/NumberExtensions.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +164,7 @@ public static boolean operator_greaterEqualsThan(Number left, Number right) { BigDecimal leftValue = numberToBigDecimal(left); BigDecimal rightValue = numberToBigDecimal(right); if (leftValue == null) { - return (rightValue != null) ? false : true; + return rightValue == null; } else if (rightValue == null) { return true; } else { @@ -178,7 +178,7 @@ public static boolean operator_equals(Type type, Number x) { if (type instanceof QuantityType qtype && x instanceof QuantityType qx) { return operator_equals(qtype, qx); } - if (type != null && type instanceof DecimalType decimalType && x != null) { + if (type instanceof DecimalType decimalType && x != null) { return decimalType.toBigDecimal().compareTo(numberToBigDecimal(x)) == 0; } else { return type == x; // both might be null, then we should return true @@ -189,7 +189,7 @@ public static boolean operator_notEquals(Type type, Number x) { if (type instanceof QuantityType qtype && x instanceof QuantityType qx) { return operator_notEquals(qtype, qx); } - if (type != null && type instanceof DecimalType decimalType && x != null) { + if (type instanceof DecimalType decimalType && x != null) { return decimalType.toBigDecimal().compareTo(numberToBigDecimal(x)) != 0; } else { return type != x; // both might be null, then we should return @@ -201,7 +201,7 @@ public static boolean operator_greaterThan(Type type, Number x) { if (type instanceof QuantityType qtype && x instanceof QuantityType qx) { return operator_greaterThan(qtype, qx); } - if (type != null && type instanceof DecimalType decimalType && x != null) { + if (type instanceof DecimalType decimalType && x != null) { return decimalType.toBigDecimal().compareTo(numberToBigDecimal(x)) > 0; } else { return false; @@ -212,7 +212,7 @@ public static boolean operator_greaterEqualsThan(Type type, Number x) { if (type instanceof QuantityType qtype && x instanceof QuantityType qx) { return operator_greaterEqualsThan(qtype, qx); } - if (type != null && type instanceof DecimalType decimalType && x != null) { + if (type instanceof DecimalType decimalType && x != null) { return decimalType.toBigDecimal().compareTo(numberToBigDecimal(x)) >= 0; } else { return false; @@ -223,7 +223,7 @@ public static boolean operator_lessThan(Type type, Number x) { if (type instanceof QuantityType qtype && x instanceof QuantityType qx) { return operator_lessThan(qtype, qx); } - if (type != null && type instanceof DecimalType decimalType && x != null) { + if (type instanceof DecimalType decimalType && x != null) { return decimalType.toBigDecimal().compareTo(numberToBigDecimal(x)) < 0; } else { return false; @@ -234,7 +234,7 @@ public static boolean operator_lessEqualsThan(Type type, Number x) { if (type instanceof QuantityType qtype && x instanceof QuantityType qx) { return operator_lessEqualsThan(qtype, qx); } - if (type != null && type instanceof DecimalType decimalType && x != null) { + if (type instanceof DecimalType decimalType && x != null) { return decimalType.toBigDecimal().compareTo(numberToBigDecimal(x)) <= 0; } else { return false; diff --git a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/scoping/ActionClassLoader.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/scoping/ActionClassLoader.java index 49be1a7ec4f..72f9dc4e7d5 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/scoping/ActionClassLoader.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/scoping/ActionClassLoader.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/scoping/ScriptImplicitlyImportedTypes.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/scoping/ScriptImplicitlyImportedTypes.java index b16396532a3..95d31c118db 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/scoping/ScriptImplicitlyImportedTypes.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/scoping/ScriptImplicitlyImportedTypes.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/scoping/ScriptImportSectionNamespaceScopeProvider.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/scoping/ScriptImportSectionNamespaceScopeProvider.java index 3bdf97944af..a3ca988ec87 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/scoping/ScriptImportSectionNamespaceScopeProvider.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/scoping/ScriptImportSectionNamespaceScopeProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/scoping/ScriptScopeProvider.xtend b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/scoping/ScriptScopeProvider.xtend index 28c7e0cd696..d9966e7a862 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/scoping/ScriptScopeProvider.xtend +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/scoping/ScriptScopeProvider.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/scoping/StateAndCommandProvider.java b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/scoping/StateAndCommandProvider.java index 3570cdbcfd6..bd1c186d650 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/scoping/StateAndCommandProvider.java +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/scoping/StateAndCommandProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/serializer/ScriptSemanticSequencer.xtend b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/serializer/ScriptSemanticSequencer.xtend index eee8b5368f7..9bfb8b64dde 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/serializer/ScriptSemanticSequencer.xtend +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/serializer/ScriptSemanticSequencer.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/serializer/ScriptSyntacticSequencer.xtend b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/serializer/ScriptSyntacticSequencer.xtend index a3b0b9b508b..3f091e794a2 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/serializer/ScriptSyntacticSequencer.xtend +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/serializer/ScriptSyntacticSequencer.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.script/src/org/openhab/core/model/script/validation/ScriptValidator.xtend b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/validation/ScriptValidator.xtend index dd698c89ddd..cce18fb5d14 100644 --- a/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/validation/ScriptValidator.xtend +++ b/bundles/org.openhab.core.model.script/src/org/openhab/core/model/script/validation/ScriptValidator.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.sitemap.ide/pom.xml b/bundles/org.openhab.core.model.sitemap.ide/pom.xml index 6dd2078c880..2de27b1e232 100644 --- a/bundles/org.openhab.core.model.sitemap.ide/pom.xml +++ b/bundles/org.openhab.core.model.sitemap.ide/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.sitemap.ide diff --git a/bundles/org.openhab.core.model.sitemap.ide/src/org/openhab/core/model/sitemap/ide/SitemapIdeModule.xtend b/bundles/org.openhab.core.model.sitemap.ide/src/org/openhab/core/model/sitemap/ide/SitemapIdeModule.xtend index ebd006b17a9..742d2bb66d7 100644 --- a/bundles/org.openhab.core.model.sitemap.ide/src/org/openhab/core/model/sitemap/ide/SitemapIdeModule.xtend +++ b/bundles/org.openhab.core.model.sitemap.ide/src/org/openhab/core/model/sitemap/ide/SitemapIdeModule.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.sitemap.ide/src/org/openhab/core/model/sitemap/ide/SitemapIdeSetup.xtend b/bundles/org.openhab.core.model.sitemap.ide/src/org/openhab/core/model/sitemap/ide/SitemapIdeSetup.xtend index 42e29b8ff67..754d245ca70 100644 --- a/bundles/org.openhab.core.model.sitemap.ide/src/org/openhab/core/model/sitemap/ide/SitemapIdeSetup.xtend +++ b/bundles/org.openhab.core.model.sitemap.ide/src/org/openhab/core/model/sitemap/ide/SitemapIdeSetup.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.sitemap.runtime/pom.xml b/bundles/org.openhab.core.model.sitemap.runtime/pom.xml index 129184a9705..d7aa132ba3d 100644 --- a/bundles/org.openhab.core.model.sitemap.runtime/pom.xml +++ b/bundles/org.openhab.core.model.sitemap.runtime/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.sitemap.runtime diff --git a/bundles/org.openhab.core.model.sitemap.runtime/src/org/openhab/core/model/sitemap/runtime/internal/SitemapRuntimeActivator.java b/bundles/org.openhab.core.model.sitemap.runtime/src/org/openhab/core/model/sitemap/runtime/internal/SitemapRuntimeActivator.java index f8aff939313..d9923bafb0b 100644 --- a/bundles/org.openhab.core.model.sitemap.runtime/src/org/openhab/core/model/sitemap/runtime/internal/SitemapRuntimeActivator.java +++ b/bundles/org.openhab.core.model.sitemap.runtime/src/org/openhab/core/model/sitemap/runtime/internal/SitemapRuntimeActivator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.sitemap/pom.xml b/bundles/org.openhab.core.model.sitemap/pom.xml index de71ef4e022..4e76aa43fd3 100644 --- a/bundles/org.openhab.core.model.sitemap/pom.xml +++ b/bundles/org.openhab.core.model.sitemap/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.sitemap diff --git a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/GenerateSitemap.mwe2 b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/GenerateSitemap.mwe2 index f050456ae42..11584396461 100644 --- a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/GenerateSitemap.mwe2 +++ b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/GenerateSitemap.mwe2 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.sitemap/src/org/openhab/core/model/sitemap/Sitemap.xtext b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/Sitemap.xtext index 4b443dd23d6..376798e473d 100644 --- a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/Sitemap.xtext +++ b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/Sitemap.xtext @@ -127,7 +127,8 @@ Slider: ('icon=[' (IconRules+=IconRule (',' IconRules+=IconRule)*) ']') | ('staticIcon=' staticIcon=Icon))? & ('sendFrequency=' frequency=INT)? & (switchEnabled?='switchSupport')? & - ('minValue=' minValue=Number)? & ('maxValue=' maxValue=Number)? & ('step=' step=Number)? & + (releaseOnly?='releaseOnly')? & ('minValue=' minValue=Number)? & + ('maxValue=' maxValue=Number)? & ('step=' step=Number)? & ('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)*) ']')? & ('valuecolor=[' (ValueColor+=ColorArray (',' ValueColor+=ColorArray)*) ']')? & ('iconcolor=[' (IconColor+=ColorArray (',' IconColor+=ColorArray)*) ']')? & @@ -182,7 +183,6 @@ Buttongrid: (('icon=' icon=Icon) | ('icon=[' (IconRules+=IconRule (',' IconRules+=IconRule)*) ']') | ('staticIcon=' staticIcon=Icon))? & - ('columns=' columns=INT) & ('buttons=[' buttons+=Button (',' buttons+=Button)* ']') & ('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)*) ']')? & ('valuecolor=[' (ValueColor+=ColorArray (',' ValueColor+=ColorArray)*) ']')? & @@ -201,7 +201,7 @@ Default: ('visibility=[' (Visibility+=VisibilityRule (',' Visibility+=VisibilityRule)*) ']')?); Button: - position=INT ':' cmd=Command '=' label=(ID | STRING) ('=' icon=Icon)?; + row=INT ':' column=INT ':' cmd=Command '=' label=(ID | STRING) ('=' icon=Icon)?; Mapping: cmd=Command '=' label=(ID | STRING) ('=' icon=Icon)?; diff --git a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/SitemapProvider.java b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/SitemapProvider.java index adc4025466f..51879430de4 100644 --- a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/SitemapProvider.java +++ b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/SitemapProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.sitemap/src/org/openhab/core/model/sitemap/SitemapRuntimeModule.xtend b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/SitemapRuntimeModule.xtend index 748dcd4e477..3efd6b8d297 100644 --- a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/SitemapRuntimeModule.xtend +++ b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/SitemapRuntimeModule.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.sitemap/src/org/openhab/core/model/sitemap/SitemapStandaloneSetup.xtend b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/SitemapStandaloneSetup.xtend index 41ea9f76510..0ac2e00ed33 100644 --- a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/SitemapStandaloneSetup.xtend +++ b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/SitemapStandaloneSetup.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.sitemap/src/org/openhab/core/model/sitemap/formatting/SitemapFormatter.xtend b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/formatting/SitemapFormatter.xtend index b0272142f5f..6e48553ba1a 100644 --- a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/formatting/SitemapFormatter.xtend +++ b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/formatting/SitemapFormatter.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.sitemap/src/org/openhab/core/model/sitemap/generator/SitemapGenerator.xtend b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/generator/SitemapGenerator.xtend index b36ba507832..8cabdb36fcb 100644 --- a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/generator/SitemapGenerator.xtend +++ b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/generator/SitemapGenerator.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.sitemap/src/org/openhab/core/model/sitemap/internal/SitemapProviderImpl.java b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/internal/SitemapProviderImpl.java index 16242356752..f444fff8246 100644 --- a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/internal/SitemapProviderImpl.java +++ b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/internal/SitemapProviderImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.sitemap/src/org/openhab/core/model/sitemap/scoping/SitemapScopeProvider.xtend b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/scoping/SitemapScopeProvider.xtend index 192815ec583..76bf9027c17 100644 --- a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/scoping/SitemapScopeProvider.xtend +++ b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/scoping/SitemapScopeProvider.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.sitemap/src/org/openhab/core/model/sitemap/serializer/SitemapSemanticSequencer.xtend b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/serializer/SitemapSemanticSequencer.xtend index 6384e614d07..16b65a0fc07 100644 --- a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/serializer/SitemapSemanticSequencer.xtend +++ b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/serializer/SitemapSemanticSequencer.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.sitemap/src/org/openhab/core/model/sitemap/serializer/SitemapSyntacticSequencer.xtend b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/serializer/SitemapSyntacticSequencer.xtend index aa0fa9cd05f..6448eec52a9 100644 --- a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/serializer/SitemapSyntacticSequencer.xtend +++ b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/serializer/SitemapSyntacticSequencer.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.sitemap/src/org/openhab/core/model/sitemap/validation/SitemapValidator.xtend b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/validation/SitemapValidator.xtend index 9aa2c13a320..398d1a22cca 100644 --- a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/validation/SitemapValidator.xtend +++ b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/validation/SitemapValidator.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.sitemap/src/org/openhab/core/model/sitemap/valueconverter/SitemapConverters.java b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/valueconverter/SitemapConverters.java index 8b50586fc65..33c83c75a8c 100644 --- a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/valueconverter/SitemapConverters.java +++ b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/valueconverter/SitemapConverters.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 @@ public class SitemapConverters extends DefaultTerminalConverters { @ValueConverter(rule = "Icon") public IValueConverter Icon() { - return new IValueConverter() { + return new IValueConverter<>() { @Override public String toValue(String string, INode node) throws ValueConverterException { @@ -50,7 +50,7 @@ public String toString(String value) throws ValueConverterException { @ValueConverter(rule = "Command") public IValueConverter Command() { - return new AbstractNullSafeConverter() { + return new AbstractNullSafeConverter<>() { @Override protected String internalToValue(String string, INode node) { if ((string.startsWith("'") && string.endsWith("'")) diff --git a/bundles/org.openhab.core.model.thing.ide/pom.xml b/bundles/org.openhab.core.model.thing.ide/pom.xml index feb6483a37c..eec22690e33 100644 --- a/bundles/org.openhab.core.model.thing.ide/pom.xml +++ b/bundles/org.openhab.core.model.thing.ide/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.thing.ide diff --git a/bundles/org.openhab.core.model.thing.ide/src/org/openhab/core/model/thing/ide/ThingIdeModule.xtend b/bundles/org.openhab.core.model.thing.ide/src/org/openhab/core/model/thing/ide/ThingIdeModule.xtend index cb929270729..ec89376396d 100644 --- a/bundles/org.openhab.core.model.thing.ide/src/org/openhab/core/model/thing/ide/ThingIdeModule.xtend +++ b/bundles/org.openhab.core.model.thing.ide/src/org/openhab/core/model/thing/ide/ThingIdeModule.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.thing.ide/src/org/openhab/core/model/thing/ide/ThingIdeSetup.xtend b/bundles/org.openhab.core.model.thing.ide/src/org/openhab/core/model/thing/ide/ThingIdeSetup.xtend index e19c7ceac41..03c6e233003 100644 --- a/bundles/org.openhab.core.model.thing.ide/src/org/openhab/core/model/thing/ide/ThingIdeSetup.xtend +++ b/bundles/org.openhab.core.model.thing.ide/src/org/openhab/core/model/thing/ide/ThingIdeSetup.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.thing.runtime/pom.xml b/bundles/org.openhab.core.model.thing.runtime/pom.xml index f97a5278d38..d002421a761 100644 --- a/bundles/org.openhab.core.model.thing.runtime/pom.xml +++ b/bundles/org.openhab.core.model.thing.runtime/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.thing.runtime diff --git a/bundles/org.openhab.core.model.thing.runtime/src/org/openhab/core/model/thing/runtime/internal/ThingRuntimeActivator.java b/bundles/org.openhab.core.model.thing.runtime/src/org/openhab/core/model/thing/runtime/internal/ThingRuntimeActivator.java index ef6377dadfe..5accdef64d8 100644 --- a/bundles/org.openhab.core.model.thing.runtime/src/org/openhab/core/model/thing/runtime/internal/ThingRuntimeActivator.java +++ b/bundles/org.openhab.core.model.thing.runtime/src/org/openhab/core/model/thing/runtime/internal/ThingRuntimeActivator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.thing/pom.xml b/bundles/org.openhab.core.model.thing/pom.xml index 8ddac3a2890..bd63f8b49d9 100644 --- a/bundles/org.openhab.core.model.thing/pom.xml +++ b/bundles/org.openhab.core.model.thing/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.model.thing diff --git a/bundles/org.openhab.core.model.thing/src.moved/test/java/org/openhab/core/model/thing/internal/GenericThingProviderMultipleBundlesTest.java b/bundles/org.openhab.core.model.thing/src.moved/test/java/org/openhab/core/model/thing/internal/GenericThingProviderMultipleBundlesTest.java index d3f35e6b793..081b6e7962c 100644 --- a/bundles/org.openhab.core.model.thing/src.moved/test/java/org/openhab/core/model/thing/internal/GenericThingProviderMultipleBundlesTest.java +++ b/bundles/org.openhab.core.model.thing/src.moved/test/java/org/openhab/core/model/thing/internal/GenericThingProviderMultipleBundlesTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.thing/src/org/openhab/core/model/thing/GenerateThing.mwe2 b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/GenerateThing.mwe2 index 4bf9f7c9f86..90fa6898d5a 100644 --- a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/GenerateThing.mwe2 +++ b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/GenerateThing.mwe2 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.thing/src/org/openhab/core/model/thing/ThingRuntimeModule.xtend b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/ThingRuntimeModule.xtend index c0f35e9a9d7..0365f792b49 100644 --- a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/ThingRuntimeModule.xtend +++ b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/ThingRuntimeModule.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.thing/src/org/openhab/core/model/thing/ThingStandaloneSetup.xtend b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/ThingStandaloneSetup.xtend index fad2b8c8675..c7a26763e31 100644 --- a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/ThingStandaloneSetup.xtend +++ b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/ThingStandaloneSetup.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.thing/src/org/openhab/core/model/thing/formatting/ThingFormatter.xtend b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/formatting/ThingFormatter.xtend index 7f946285220..e008ac6cc92 100644 --- a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/formatting/ThingFormatter.xtend +++ b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/formatting/ThingFormatter.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.thing/src/org/openhab/core/model/thing/generator/ThingGenerator.xtend b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/generator/ThingGenerator.xtend index 6f7bcd96c3c..3a6e5ed2898 100644 --- a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/generator/ThingGenerator.xtend +++ b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/generator/ThingGenerator.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.thing/src/org/openhab/core/model/thing/internal/AbstractProviderLazyNullness.java b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/AbstractProviderLazyNullness.java index 38c4dd34345..16bb50aa2ea 100644 --- a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/AbstractProviderLazyNullness.java +++ b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/AbstractProviderLazyNullness.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.thing/src/org/openhab/core/model/thing/internal/GenericItemChannelLinkProvider.java b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/GenericItemChannelLinkProvider.java index 73317d9610c..7a386b17aa6 100644 --- a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/GenericItemChannelLinkProvider.java +++ b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/GenericItemChannelLinkProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,8 +13,10 @@ package org.openhab.core.model.thing.internal; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -44,8 +46,8 @@ public class GenericItemChannelLinkProvider extends AbstractProvider> itemChannelLinkMap = new ConcurrentHashMap<>(); + /** caches binding configurations. maps itemNames to {@link ItemChannelLink}s */ + protected Map> itemChannelLinkMap = new ConcurrentHashMap<>(); /** * stores information about the context of items. The map has this content @@ -80,7 +82,7 @@ public void processBindingConfiguration(String context, String itemType, String private void createItemChannelLink(String context, String itemName, String channelUID, Configuration configuration) throws BindingConfigParseException { - ChannelUID channelUIDObject = null; + ChannelUID channelUIDObject; try { channelUIDObject = new ChannelUID(channelUID); } catch (IllegalArgumentException e) { @@ -88,25 +90,23 @@ private void createItemChannelLink(String context, String itemName, String chann } ItemChannelLink itemChannelLink = new ItemChannelLink(itemName, channelUIDObject, configuration); - Set itemNames = contextMap.get(context); - if (itemNames == null) { - itemNames = new HashSet<>(); - contextMap.put(context, itemNames); - } + Set itemNames = Objects.requireNonNull(contextMap.computeIfAbsent(context, k -> new HashSet<>())); itemNames.add(itemName); if (previousItemNames != null) { previousItemNames.remove(itemName); } - Set links = itemChannelLinkMap.get(itemName); - if (links == null) { - itemChannelLinkMap.put(itemName, links = new HashSet<>()); - } - if (!links.contains(itemChannelLink)) { - links.add(itemChannelLink); + // Create a HashMap with an initial capacity of 2 (the default is 16) to save memory because most items have + // only one channel. A capacity of 2 is enough to avoid resizing the HashMap in most cases, whereas 1 would + // trigger a resize as soon as one element is added. + Map links = Objects + .requireNonNull(itemChannelLinkMap.computeIfAbsent(itemName, k -> new HashMap<>(2))); + + ItemChannelLink oldLink = links.put(channelUIDObject, itemChannelLink); + if (oldLink == null) { notifyListenersAboutAddedElement(itemChannelLink); } else { - notifyListenersAboutUpdatedElement(itemChannelLink, itemChannelLink); + notifyListenersAboutUpdatedElement(oldLink, itemChannelLink); } } @@ -128,11 +128,9 @@ public void stopConfigurationUpdate(String context) { } for (String itemName : previousItemNames) { // we remove all binding configurations that were not processed - Set links = itemChannelLinkMap.remove(itemName); + Map links = itemChannelLinkMap.remove(itemName); if (links != null) { - for (ItemChannelLink removedItemChannelLink : links) { - notifyListenersAboutRemovedElement(removedItemChannelLink); - } + links.values().forEach(this::notifyListenersAboutRemovedElement); } } Optional.ofNullable(contextMap.get(context)).ifPresent(ctx -> ctx.removeAll(previousItemNames)); @@ -140,6 +138,6 @@ public void stopConfigurationUpdate(String context) { @Override public Collection getAll() { - return itemChannelLinkMap.values().stream().flatMap(Collection::stream).toList(); + return itemChannelLinkMap.values().stream().flatMap(m -> m.values().stream()).toList(); } } diff --git a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/GenericThingProvider.xtend b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/GenericThingProvider.xtend index ff49a98dba6..b9475f558f1 100644 --- a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/GenericThingProvider.xtend +++ b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/GenericThingProvider.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.thing/src/org/openhab/core/model/thing/scoping/ThingScopeProvider.xtend b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/scoping/ThingScopeProvider.xtend index 535c32570cd..933bed58d03 100644 --- a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/scoping/ThingScopeProvider.xtend +++ b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/scoping/ThingScopeProvider.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.thing/src/org/openhab/core/model/thing/serializer/ThingSemanticSequencer.xtend b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/serializer/ThingSemanticSequencer.xtend index f3eeb1a1a4c..3bd51bde5c0 100644 --- a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/serializer/ThingSemanticSequencer.xtend +++ b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/serializer/ThingSemanticSequencer.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.thing/src/org/openhab/core/model/thing/serializer/ThingSyntacticSequencer.xtend b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/serializer/ThingSyntacticSequencer.xtend index b13809cd00b..cbd130e7772 100644 --- a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/serializer/ThingSyntacticSequencer.xtend +++ b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/serializer/ThingSyntacticSequencer.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.thing/src/org/openhab/core/model/thing/serializer/ThingSyntacticSequencerExtension.java b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/serializer/ThingSyntacticSequencerExtension.java index 60ea5b98362..880540ee2d9 100644 --- a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/serializer/ThingSyntacticSequencerExtension.java +++ b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/serializer/ThingSyntacticSequencerExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.thing/src/org/openhab/core/model/thing/validation/ThingValidator.xtend b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/validation/ThingValidator.xtend index 6d36230efe7..7171a6197d5 100644 --- a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/validation/ThingValidator.xtend +++ b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/validation/ThingValidator.xtend @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.thing/src/org/openhab/core/model/thing/valueconverter/ThingValueConverters.java b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/valueconverter/ThingValueConverters.java index 1913ee8c33e..2799f796678 100644 --- a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/valueconverter/ThingValueConverters.java +++ b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/valueconverter/ThingValueConverters.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.model.thing/src/org/openhab/core/model/thing/valueconverter/UIDtoStringConverter.java b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/valueconverter/UIDtoStringConverter.java index 4923afbdc66..527c25586c5 100644 --- a/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/valueconverter/UIDtoStringConverter.java +++ b/bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/valueconverter/UIDtoStringConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,9 +12,6 @@ */ package org.openhab.core.model.thing.valueconverter; -import java.util.Arrays; -import java.util.stream.Collectors; - import org.eclipse.xtext.conversion.IValueConverter; import org.eclipse.xtext.conversion.ValueConverterException; import org.eclipse.xtext.nodemodel.INode; @@ -30,14 +27,14 @@ */ public class UIDtoStringConverter implements IValueConverter { - private static final String SEPERATOR = ":"; + private static final String SEPARATOR = ":"; @Override public String toValue(final String string, INode node) throws ValueConverterException { if (string == null) { return null; } - String[] ids = string.split(SEPERATOR); + String[] ids = string.split(SEPARATOR); for (int i = 0; i < ids.length; i++) { String id = ids[i]; if (id != null && id.startsWith("\"") && id.endsWith("\"")) { @@ -48,7 +45,7 @@ public String toValue(final String string, INode node) throws ValueConverterExce } } } - return Arrays.stream(ids).collect(Collectors.joining(SEPERATOR)); + return String.join(SEPARATOR, ids); } @Override @@ -56,7 +53,7 @@ public String toString(String value) throws ValueConverterException { if (value == null) { throw new ValueConverterException("Value may not be null.", null, null); } - String[] ids = value.split(SEPERATOR); + String[] ids = value.split(SEPARATOR); for (int i = 0; i < ids.length; i++) { String id = ids[i]; if (id != null && !id.matches("[A-Za-z0-9_]*")) { @@ -65,7 +62,7 @@ public String toString(String value) throws ValueConverterException { ids[i] = toEscapedString(id); } } - return Arrays.stream(ids).collect(Collectors.joining(SEPERATOR)); + return String.join(SEPARATOR, ids); } protected String toEscapedString(String value) { diff --git a/bundles/org.openhab.core.model.yaml/.classpath b/bundles/org.openhab.core.model.yaml/.classpath new file mode 100644 index 00000000000..58cd399d639 --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/.classpath @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.openhab.core.model.yaml/.project b/bundles/org.openhab.core.model.yaml/.project new file mode 100644 index 00000000000..1b130d3a787 --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/.project @@ -0,0 +1,23 @@ + + + org.openhab.core.model.yaml + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/bundles/org.openhab.core.model.yaml/NOTICE b/bundles/org.openhab.core.model.yaml/NOTICE new file mode 100644 index 00000000000..19bf5f2cfa8 --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/NOTICE @@ -0,0 +1,14 @@ +This content is produced and maintained by the openHAB project. + +* Project home: https://www.openhab.org + +== Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License 2.0 which is available at +https://www.eclipse.org/legal/epl-2.0/. + +== Source Code + +https://github.com/openhab/openhab-core + diff --git a/bundles/org.openhab.core.model.yaml/pom.xml b/bundles/org.openhab.core.model.yaml/pom.xml new file mode 100644 index 00000000000..d9ee59f9cf3 --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/pom.xml @@ -0,0 +1,29 @@ + + + + 4.0.0 + + + org.openhab.core.bundles + org.openhab.core.reactor.bundles + 4.2.0-SNAPSHOT + + + org.openhab.core.model.yaml + + openHAB Core :: Bundles :: Model YAML + + + + org.openhab.core.bundles + org.openhab.core + ${project.version} + + + org.openhab.core.bundles + org.openhab.core.semantics + ${project.version} + + + diff --git a/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/YamlElement.java b/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/YamlElement.java new file mode 100644 index 00000000000..5eda852fbf0 --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/YamlElement.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.model.yaml; + +import org.eclipse.jdt.annotation.NonNull; +import org.openhab.core.model.yaml.internal.YamlModelRepositoryImpl; + +/** + * The {@link YamlElement} interface must be implemented by any classes that need to be handled by the + * {@link YamlModelRepositoryImpl}. + *

        + * Implementations + *

          + *
        • MUST have a default constructor to allow deserialization with Jackson
        • + *
        • MUST provide {@code equals(Object other)} and {@code hashcode()} methods
        • + *
        • MUST be annotated with {@link YamlElementName} containing the element name
        • + *
        • SHOULD implement a proper {@code toString()} method
        • + *
        + * + * @author Laurent Garnier - Initial contribution + * @author Jan N. Klug - Refactoring and improvements to JavaDoc + */ +public interface YamlElement { + + /** + * Get the identifier of this element. + *

        + *

        + * Identifiers + *

          + *
        • MUST be non-null
        • + *
        • MUST be unique within a model
        • + *
        • SHOULD be unique across all models
        • + *
        + * + * @return the identifier as a string + */ + @NonNull + String getId(); + + /** + * Check if this element is valid and should be included in the model. + *

        + *

        + * Implementations + *

          + *
        • MUST check that at least {link #getId()} returns a non-null value
        • + *
        • SHOULD log the reason of failed checks at WARN level
        • + *
        • MAY perform additional checks
        • + *
        + * + * @return {@code true} if all the checks are completed successfully + */ + boolean isValid(); +} diff --git a/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/YamlElementName.java b/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/YamlElementName.java new file mode 100644 index 00000000000..4e0080ebb3d --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/YamlElementName.java @@ -0,0 +1,28 @@ +/** + * 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.model.yaml; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * The {@link YamlElementName} is a required annotation for the inheritors of {@link YamlElement}. It specifies the root + * element name in a YAML model that is described by the respective class. Code review MUST ensure that element names + * are unique. + * + * @author Jan N. Klug - Initial contribution + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface YamlElementName { + String value(); +} diff --git a/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/YamlModelListener.java b/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/YamlModelListener.java new file mode 100644 index 00000000000..3366ad5e082 --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/YamlModelListener.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.model.yaml; + +import java.util.Collection; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * The {@link YamlModelListener} interface is responsible for managing a particular model type + * with data processed from YAML configuration files. + *

        + * Implementors are notified whenever a YAML model changed that contains elements of the given type. They MUST declare + * at least {@link YamlModelListener} as service to automatically register them with the repository. + * + * @author Laurent Garnier - Initial contribution + */ +@NonNullByDefault +public interface YamlModelListener { + + /** + * Method called by the model repository when elements from a model are added. Only added elements are contained in + * the collection. In case the listener is added after a model was read, this method is also called with all + * elements from that model. + * + * @param modelName the name of the model + * @param elements the collection of added elements + */ + void addedModel(String modelName, Collection elements); + + /** + * Method called by the model repository when elements from a model are updated. Only changed elements are contained + * in the collection. + * + * @param modelName the name of the model + * @param elements the collection of updated elements + */ + void updatedModel(String modelName, Collection elements); + + /** + * Method called by the model repository when elements from a model are removed. + * + * @param modelName the name of the model + * @param elements the collection of removed elements + */ + void removedModel(String modelName, Collection elements); + + /** + * Get the DTO class to be used for each object of this model type. The DTO class MUST implement {@link YamlElement} + * and fulfill all requirements defined for the interface. + * + * @return the DTO element class + */ + Class getElementClass(); +} diff --git a/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/YamlModelRepository.java b/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/YamlModelRepository.java new file mode 100644 index 00000000000..c4f074a243b --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/YamlModelRepository.java @@ -0,0 +1,29 @@ +/** + * 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.model.yaml; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * The {@link YamlModelRepository} defines methods to update elements in a YAML model. + * + * @author Jan N. Klug - Initial contribution + */ +@NonNullByDefault +public interface YamlModelRepository { + void addElementToModel(String modelName, YamlElement element); + + void removeElementFromModel(String modelName, YamlElement element); + + void updateElementInModel(String modelName, YamlElement element); +} diff --git a/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/YamlModelRepositoryImpl.java b/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/YamlModelRepositoryImpl.java new file mode 100644 index 00000000000..228f2cf418f --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/YamlModelRepositoryImpl.java @@ -0,0 +1,428 @@ +/** + * 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.model.yaml.internal; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.stream.Collectors; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.core.model.yaml.YamlElement; +import org.openhab.core.model.yaml.YamlElementName; +import org.openhab.core.model.yaml.YamlModelListener; +import org.openhab.core.model.yaml.YamlModelRepository; +import org.openhab.core.service.WatchService; +import org.openhab.core.service.WatchService.Kind; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +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; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.PropertyAccessor; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; + +/** + * The {@link YamlModelRepositoryImpl} is an OSGi service, that encapsulates all YAML file processing + * including file monitoring to detect created, updated and removed YAML configuration files. + * Data processed from these files are consumed by registered OSGi services that implement {@link YamlModelListener}. + * + * @author Laurent Garnier - Initial contribution + * @author Jan N. Klug - Refactored for multiple types per file and add modifying possibility + */ +@NonNullByDefault +@Component(immediate = true) +public class YamlModelRepositoryImpl implements WatchService.WatchEventListener, YamlModelRepository { + private static final int DEFAULT_MODEL_VERSION = 1; + private final Logger logger = LoggerFactory.getLogger(YamlModelRepositoryImpl.class); + + private final WatchService watchService; + private final Path watchPath; + private final ObjectMapper objectMapper; + + private final Map>> elementListeners = new ConcurrentHashMap<>(); + // all model nodes, ordered by model name (full path as string) and type + private final Map modelCache = new ConcurrentHashMap<>(); + + @Activate + public YamlModelRepositoryImpl(@Reference(target = WatchService.CONFIG_WATCHER_FILTER) WatchService watchService) { + YAMLFactory yamlFactory = YAMLFactory.builder() // + .disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER) // omit "---" at file start + .disable(YAMLGenerator.Feature.SPLIT_LINES) // do not split long lines + .enable(YAMLGenerator.Feature.INDENT_ARRAYS_WITH_INDICATOR) // indent arrays + .enable(YAMLGenerator.Feature.MINIMIZE_QUOTES) // use quotes only where necessary + .build(); + this.objectMapper = new ObjectMapper(yamlFactory); + objectMapper.findAndRegisterModules(); + objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); + objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); + + this.watchService = watchService; + watchService.registerListener(this, Path.of("")); + watchPath = watchService.getWatchPath(); + } + + @Deactivate + public void deactivate() { + watchService.unregisterListener(this); + } + + // The method is "synchronized" to avoid concurrent files processing + @Override + @SuppressWarnings({ "rawtypes", "unchecked" }) + public synchronized void processWatchEvent(Kind kind, Path path) { + Path fullPath = watchPath.resolve(path); + String pathString = path.toString(); + if (Files.isDirectory(fullPath) || fullPath.toFile().isHidden() || !pathString.endsWith(".yaml")) { + logger.trace("Ignored {}", fullPath); + return; + } + + // strip extension for model name + String modelName = pathString.substring(0, pathString.lastIndexOf(".")); + + if (kind == WatchService.Kind.DELETE) { + logger.info("Removing YAML model {}", modelName); + YamlModelWrapper removedModel = modelCache.remove(modelName); + if (removedModel == null) { + return; + } + for (Map.Entry> modelEntry : removedModel.getNodes().entrySet()) { + String elementName = modelEntry.getKey(); + List removedNodes = modelEntry.getValue(); + if (!removedNodes.isEmpty()) { + getElementListeners(elementName).forEach(listener -> { + List removedElements = parseJsonNodes(removedNodes, listener.getElementClass()); + listener.removedModel(modelName, removedElements); + }); + } + } + } else { + if (kind == Kind.CREATE) { + logger.info("Adding YAML model {}", modelName); + } else { + logger.info("Updating YAML model {}", modelName); + } + try { + JsonNode fileContent = objectMapper.readTree(fullPath.toFile()); + + // check version + JsonNode versionNode = fileContent.get("version"); + if (versionNode == null || !versionNode.canConvertToInt()) { + logger.warn("Version is missing or not a number in model {}. Ignoring it.", modelName); + return; + } + int modelVersion = versionNode.asInt(); + if (modelVersion != DEFAULT_MODEL_VERSION) { + logger.warn("Model {} has version {}, but only version 1 is supported. Ignoring it.", modelName, + modelVersion); + return; + } + JsonNode readOnlyNode = fileContent.get("readOnly"); + boolean readOnly = readOnlyNode == null || readOnlyNode.asBoolean(false); + + YamlModelWrapper model = Objects.requireNonNull( + modelCache.computeIfAbsent(modelName, k -> new YamlModelWrapper(modelVersion, readOnly))); + + // get sub-elements + Iterator> it = fileContent.fields(); + while (it.hasNext()) { + Map.Entry element = it.next(); + String elementName = element.getKey(); + JsonNode node = element.getValue(); + if (!node.isArray()) { + // all processable sub-elements are arrays + logger.trace("Element {} in model {} is not an array, ignoring it", elementName, modelName); + continue; + } + + List oldNodeElements = model.getNodes().getOrDefault(elementName, List.of()); + List newNodeElements = new ArrayList<>(); + node.elements().forEachRemaining(newNodeElements::add); + + for (YamlModelListener elementListener : getElementListeners(elementName)) { + Class elementClass = elementListener.getElementClass(); + + Map oldElements = listToMap( + parseJsonNodes(oldNodeElements, elementClass)); + Map newElements = listToMap( + parseJsonNodes(newNodeElements, elementClass)); + + List addedElements = newElements.values().stream() + .filter(e -> !oldElements.containsKey(e.getId())).toList(); + List removedElements = oldElements.values().stream() + .filter(e -> !newElements.containsKey(e.getId())).toList(); + List updatedElements = newElements.values().stream().filter( + e -> oldElements.containsKey(e.getId()) && !e.equals(oldElements.get(e.getId()))) + .toList(); + + if (!addedElements.isEmpty()) { + elementListener.addedModel(modelName, addedElements); + } + if (!removedElements.isEmpty()) { + elementListener.removedModel(modelName, removedElements); + } + if (!updatedElements.isEmpty()) { + elementListener.updatedModel(modelName, updatedElements); + } + } + + // replace cache + model.getNodes().put(elementName, newNodeElements); + } + } catch (IOException e) { + logger.warn("Failed to read {}: {}", modelName, e.getMessage()); + } + } + } + + @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void addYamlModelListener(YamlModelListener listener) { + Class elementClass = listener.getElementClass(); + YamlElementName annotation = elementClass.getAnnotation(YamlElementName.class); + if (annotation == null) { + logger.warn("Class {} is missing the mandatory YamlElementName annotation. This is a bug.", elementClass); + return; + } + String elementName = annotation.value(); + getElementListeners(elementName).add(listener); + + // iterate over all models and notify he new listener of already existing models with this type + for (Map.Entry model : modelCache.entrySet()) { + String modelName = model.getKey(); + List modelNodes = model.getValue().getNodes().get(elementName); + if (modelNodes == null || modelNodes.isEmpty()) { + continue; + } + List modelElements = parseJsonNodes(modelNodes, elementClass); + listener.addedModel(modelName, modelElements); + } + } + + public void removeYamlModelListener(YamlModelListener listener) { + elementListeners.values().forEach(list -> list.remove(listener)); + } + + @Override + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void addElementToModel(String modelName, YamlElement element) { + YamlElementName annotation = element.getClass().getAnnotation(YamlElementName.class); + if (annotation == null) { + logger.warn( + "Failed to add element {}. Class {}) is missing the mandatory YamlElementName annotation. This is a bug.", + element.getId(), element.getClass()); + return; + } + String elementName = annotation.value(); + YamlModelWrapper model = Objects.requireNonNull( + modelCache.computeIfAbsent(modelName, k -> new YamlModelWrapper(DEFAULT_MODEL_VERSION, false))); + if (model.isReadOnly()) { + logger.warn("Modifying {} is not allowed, model is marked read-only", modelName); + return; + } + + List modelNodes = model.getNodes().computeIfAbsent(elementName, k -> new CopyOnWriteArrayList<>()); + JsonNode newNode = objectMapper.convertValue(element, JsonNode.class); + modelNodes.add(newNode); + // notify listeners + getElementListeners(elementName).forEach(l -> { + List newElements = parseJsonNodes(List.of(newNode), l.getElementClass()); + if (!newElements.isEmpty()) { + l.addedModel(modelName, newElements); + } + }); + + writeModel(modelName); + } + + @Override + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void removeElementFromModel(String modelName, YamlElement element) { + YamlElementName annotation = element.getClass().getAnnotation(YamlElementName.class); + if (annotation == null) { + logger.warn( + "Failed to remove element {}. Class {}) is missing the mandatory YamlElementName annotation. This is a bug.", + element.getId(), element.getClass()); + return; + } + String elementName = annotation.value(); + YamlModelWrapper model = modelCache.get(modelName); + if (model == null) { + logger.warn("Failed to remove {} from model {} because the model is not known.", element, modelName); + return; + } + if (model.isReadOnly()) { + logger.warn("Modifying {} is not allowed, model is marked read-only", modelName); + return; + } + + List modelNodes = model.getNodes().get(elementName); + if (modelNodes == null) { + logger.warn("Failed to remove {} from model {} because type {} is not known in the model.", element, + modelName, elementName); + return; + } + JsonNode toRemove = findNodeById(modelNodes, element.getClass(), element.getId()); + if (toRemove == null) { + logger.warn("Failed to remove {} from model {} because element is not in model.", element, modelName); + return; + } + modelNodes.remove(toRemove); + // notify listeners + getElementListeners(elementName).forEach(l -> { + List newElements = parseJsonNodes(List.of(toRemove), l.getElementClass()); + if (!newElements.isEmpty()) { + l.addedModel(modelName, newElements); + } + }); + + writeModel(modelName); + } + + @Override + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void updateElementInModel(String modelName, YamlElement element) { + YamlElementName annotation = element.getClass().getAnnotation(YamlElementName.class); + if (annotation == null) { + logger.warn( + "Failed to update element {}. Class {}) is missing the mandatory YamlElementName annotation. This is a bug.", + element.getId(), element.getClass()); + return; + } + String elementName = annotation.value(); + YamlModelWrapper model = modelCache.get(modelName); + if (model == null) { + logger.warn("Failed to update {} in model {} because the model is not known.", element, modelName); + return; + } + if (model.isReadOnly()) { + logger.warn("Modifying {} is not allowed, model is marked read-only", modelName); + return; + } + + List modelNodes = model.getNodes().get(elementName); + if (modelNodes == null) { + logger.warn("Failed to update {} in model {} because type {} is not known in the model.", element, + modelName, elementName); + return; + } + JsonNode oldElement = findNodeById(modelNodes, element.getClass(), element.getId()); + if (oldElement == null) { + logger.warn("Failed to update {} in model {} because element is not in model.", element, modelName); + return; + } + + JsonNode newNode = objectMapper.convertValue(element, JsonNode.class); + modelNodes.set(modelNodes.indexOf(oldElement), newNode); + // notify listeners + getElementListeners(elementName).forEach(l -> { + List newElements = parseJsonNodes(List.of(newNode), l.getElementClass()); + if (!newElements.isEmpty()) { + l.updatedModel(modelName, newElements); + } + }); + + writeModel(modelName); + } + + private void writeModel(String modelName) { + YamlModelWrapper model = modelCache.get(modelName); + if (model == null) { + logger.warn("Failed to write model {} to disk because it is not known.", modelName); + return; + } + + if (model.isReadOnly()) { + logger.warn("Failed to write model {} to disk because it is marked as read-only.", modelName); + return; + } + + // create the model + JsonNodeFactory nodeFactory = objectMapper.getNodeFactory(); + ObjectNode rootNode = nodeFactory.objectNode(); + + rootNode.put("version", model.getVersion()); + rootNode.put("readOnly", model.isReadOnly()); + for (Map.Entry> elementNodes : model.getNodes().entrySet()) { + ArrayNode arrayNode = nodeFactory.arrayNode(); + elementNodes.getValue().forEach(arrayNode::add); + rootNode.set(elementNodes.getKey(), arrayNode); + } + + try { + Path outFile = watchPath.resolve(modelName + ".yaml"); + String fileContent = objectMapper.writeValueAsString(rootNode); + if (Files.exists(outFile) && !Files.isWritable(outFile)) { + logger.warn("Failed writing model {}: model exists but is read-only.", modelName); + return; + } + Files.writeString(outFile, fileContent); + } catch (JsonProcessingException e) { + logger.warn("Failed to serialize model {}: {}", modelName, e.getMessage()); + } catch (IOException e) { + logger.warn("Failed writing model {}: {}", modelName, e.getMessage()); + } + } + + private List> getElementListeners(String elementName) { + return Objects.requireNonNull(elementListeners.computeIfAbsent(elementName, k -> new CopyOnWriteArrayList<>())); + } + + private @Nullable JsonNode findNodeById(List nodes, Class elementClass, + String id) { + return nodes.stream().filter(node -> { + Optional parsedNode = parseJsonNode(node, elementClass); + return parsedNode.filter(yamlDTO -> id.equals(yamlDTO.getId())).isPresent(); + }).findAny().orElse(null); + } + + private Map listToMap(List elements) { + return elements.stream().collect(Collectors.toMap(YamlElement::getId, e -> e)); + } + + private List parseJsonNodes(List nodes, Class elementClass) { + return nodes.stream().map(nE -> parseJsonNode(nE, elementClass)).filter(Optional::isPresent).map(Optional::get) + .filter(YamlElement::isValid).toList(); + } + + private Optional parseJsonNode(JsonNode node, Class elementClass) { + try { + return Optional.of(objectMapper.treeToValue(node, elementClass)); + } catch (JsonProcessingException e) { + logger.warn("Could not parse element {} to {}: {}", node, elementClass, e.getMessage()); + return Optional.empty(); + } + } +} diff --git a/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/YamlModelWrapper.java b/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/YamlModelWrapper.java new file mode 100644 index 00000000000..d38defea935 --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/YamlModelWrapper.java @@ -0,0 +1,50 @@ +/** + * 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.model.yaml.internal; + +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +import com.fasterxml.jackson.databind.JsonNode; + +/** + * The {@link YamlModelWrapper} is used to store the information read from a model in the model cache. + * + * @author Jan N. Klug - Initial contribution + */ +@NonNullByDefault +public class YamlModelWrapper { + private final int version; + private final boolean readOnly; + private final Map> nodes = new ConcurrentHashMap<>(); + + public YamlModelWrapper(int version, boolean readOnly) { + this.version = version; + this.readOnly = readOnly; + } + + public int getVersion() { + return version; + } + + public boolean isReadOnly() { + return readOnly; + } + + public Map> getNodes() { + return nodes; + } +} diff --git a/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/semantics/YamlSemanticTagDTO.java b/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/semantics/YamlSemanticTagDTO.java new file mode 100644 index 00000000000..213a444dce8 --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/semantics/YamlSemanticTagDTO.java @@ -0,0 +1,69 @@ +/** + * 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.model.yaml.internal.semantics; + +import java.util.List; +import java.util.Objects; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.core.model.yaml.YamlElement; +import org.openhab.core.model.yaml.YamlElementName; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The {@link YamlSemanticTagDTO} is a data transfer object used to serialize a semantic tag + * in a YAML configuration file. + * + * @author Laurent Garnier - Initial contribution + */ +@YamlElementName("tags") +public class YamlSemanticTagDTO implements YamlElement { + + private final Logger logger = LoggerFactory.getLogger(YamlSemanticTagDTO.class); + + public String uid; + public String label; + public String description; + public List synonyms; + + public YamlSemanticTagDTO() { + } + + @Override + public @NonNull String getId() { + return uid; + } + + @Override + public boolean isValid() { + if (uid == null) { + logger.debug("uid missing"); + return false; + } + return true; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (this == obj) { + return true; + } else if (obj == null || getClass() != obj.getClass()) { + return false; + } + YamlSemanticTagDTO that = (YamlSemanticTagDTO) obj; + return Objects.equals(uid, that.uid) && Objects.equals(label, that.label) + && Objects.equals(description, that.description) && Objects.equals(synonyms, that.synonyms); + } +} diff --git a/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/semantics/YamlSemanticTagProvider.java b/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/semantics/YamlSemanticTagProvider.java new file mode 100644 index 00000000000..ef8b62dc4df --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/semantics/YamlSemanticTagProvider.java @@ -0,0 +1,110 @@ +/** + * 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.model.yaml.internal.semantics; + +import java.util.Collection; +import java.util.Comparator; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.core.common.registry.AbstractProvider; +import org.openhab.core.model.yaml.YamlModelListener; +import org.openhab.core.semantics.SemanticTag; +import org.openhab.core.semantics.SemanticTagImpl; +import org.openhab.core.semantics.SemanticTagProvider; +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; + +/** + * {@link YamlSemanticTagProvider} is an OSGi service, that allows to define semantic tags + * in YAML configuration files in folder conf/tags. + * Files can be added, updated or removed at runtime. + * These semantic tags are automatically exposed to the {@link org.openhab.core.semantics.SemanticTagRegistry}. + * + * @author Laurent Garnier - Initial contribution + */ +@NonNullByDefault +@Component(immediate = true, service = { SemanticTagProvider.class, YamlSemanticTagProvider.class, + YamlModelListener.class }) +public class YamlSemanticTagProvider extends AbstractProvider + implements SemanticTagProvider, YamlModelListener { + + private final Logger logger = LoggerFactory.getLogger(YamlSemanticTagProvider.class); + + private final Set tags = new TreeSet<>(Comparator.comparing(SemanticTag::getUID)); + + @Activate + public YamlSemanticTagProvider() { + } + + @Deactivate + public void deactivate() { + tags.clear(); + } + + @Override + public Collection getAll() { + return tags; + } + + @Override + public Class getElementClass() { + return YamlSemanticTagDTO.class; + } + + @Override + public void addedModel(String modelName, Collection elements) { + List added = elements.stream().map(this::mapSemanticTag) + .sorted(Comparator.comparing(SemanticTag::getUID)).toList(); + tags.addAll(added); + added.forEach(t -> { + logger.debug("model {} added tag {}", modelName, t.getUID()); + notifyListenersAboutAddedElement(t); + }); + } + + @Override + public void updatedModel(String modelName, Collection elements) { + List updated = elements.stream().map(this::mapSemanticTag).toList(); + updated.forEach(t -> { + tags.stream().filter(tag -> tag.getUID().equals(t.getUID())).findFirst().ifPresentOrElse(oldTag -> { + tags.remove(oldTag); + tags.add(t); + logger.debug("model {} updated tag {}", modelName, t.getUID()); + notifyListenersAboutUpdatedElement(oldTag, t); + }, () -> logger.debug("model {} tag {} not found", modelName, t.getUID())); + }); + } + + @Override + public void removedModel(String modelName, Collection elements) { + List removed = elements.stream().map(this::mapSemanticTag) + .sorted(Comparator.comparing(SemanticTag::getUID).reversed()).toList(); + removed.forEach(t -> { + tags.stream().filter(tag -> tag.getUID().equals(t.getUID())).findFirst().ifPresentOrElse(oldTag -> { + tags.remove(oldTag); + logger.debug("model {} removed tag {}", modelName, t.getUID()); + notifyListenersAboutRemovedElement(oldTag); + }, () -> logger.debug("model {} tag {} not found", modelName, t.getUID())); + }); + } + + private SemanticTag mapSemanticTag(YamlSemanticTagDTO tagDTO) { + return new SemanticTagImpl(tagDTO.uid, tagDTO.label, tagDTO.description, tagDTO.synonyms); + } +} diff --git a/bundles/org.openhab.core.model.yaml/src/test/java/org/openhab/core/model/yaml/internal/YamlModelRepositoryImplTest.java b/bundles/org.openhab.core.model.yaml/src/test/java/org/openhab/core/model/yaml/internal/YamlModelRepositoryImplTest.java new file mode 100644 index 00000000000..65b9368dcdc --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/test/java/org/openhab/core/model/yaml/internal/YamlModelRepositoryImplTest.java @@ -0,0 +1,264 @@ +/** + * 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.model.yaml.internal; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.*; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.util.Collection; +import java.util.List; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import org.openhab.core.model.yaml.YamlElement; +import org.openhab.core.model.yaml.YamlModelListener; +import org.openhab.core.model.yaml.test.FirstTypeDTO; +import org.openhab.core.model.yaml.test.SecondTypeDTO; +import org.openhab.core.service.WatchService; + +/** + * The {@link YamlModelRepositoryImplTest} contains tests for the {@link YamlModelRepositoryImpl} class. + * + * @author Jan N. Klug - Initial contribution + */ +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) +@NonNullByDefault +public class YamlModelRepositoryImplTest { + private static final Path SOURCE_PATH = Path.of("src/test/resources"); + private static final String MODEL_NAME = "model"; + private static final Path MODEL_PATH = Path.of(MODEL_NAME + ".yaml"); + + private @Mock @NonNullByDefault({}) WatchService watchServiceMock; + private @TempDir @NonNullByDefault({}) Path watchPath; + private @NonNullByDefault({}) Path fullModelPath; + + private @Mock @NonNullByDefault({}) YamlModelListener<@NonNull FirstTypeDTO> firstTypeListener; + private @Mock @NonNullByDefault({}) YamlModelListener<@NonNull SecondTypeDTO> secondTypeListener1; + private @Mock @NonNullByDefault({}) YamlModelListener<@NonNull SecondTypeDTO> secondTypeListener2; + + private @Captor @NonNullByDefault({}) ArgumentCaptor> firstTypeCaptor; + private @Captor @NonNullByDefault({}) ArgumentCaptor> secondTypeCaptor1; + private @Captor @NonNullByDefault({}) ArgumentCaptor> secondTypeCaptor2; + + @BeforeEach + public void setup() { + fullModelPath = watchPath.resolve(MODEL_PATH); + when(watchServiceMock.getWatchPath()).thenReturn(watchPath); + + when(firstTypeListener.getElementClass()).thenReturn(FirstTypeDTO.class); + when(secondTypeListener1.getElementClass()).thenReturn(SecondTypeDTO.class); + when(secondTypeListener2.getElementClass()).thenReturn(SecondTypeDTO.class); + } + + @Test + public void testFileAddedAfterListeners() throws IOException { + Files.copy(SOURCE_PATH.resolve("modelFileAddedOrRemoved.yaml"), fullModelPath); + + YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock); + modelRepository.addYamlModelListener(firstTypeListener); + modelRepository.addYamlModelListener(secondTypeListener1); + modelRepository.addYamlModelListener(secondTypeListener2); + + modelRepository.processWatchEvent(WatchService.Kind.CREATE, MODEL_PATH); + + verify(firstTypeListener).addedModel(eq(MODEL_NAME), firstTypeCaptor.capture()); + verify(firstTypeListener, never()).updatedModel(any(), any()); + verify(firstTypeListener, never()).removedModel(any(), any()); + verify(secondTypeListener1).addedModel(eq(MODEL_NAME), secondTypeCaptor1.capture()); + verify(secondTypeListener1, never()).updatedModel(any(), any()); + verify(secondTypeListener1, never()).removedModel(any(), any()); + verify(secondTypeListener2).addedModel(eq(MODEL_NAME), secondTypeCaptor2.capture()); + verify(secondTypeListener2, never()).updatedModel(any(), any()); + verify(secondTypeListener2, never()).removedModel(any(), any()); + + Collection firstTypeElements = firstTypeCaptor.getValue(); + Collection secondTypeElements1 = secondTypeCaptor1.getValue(); + Collection secondTypeElements2 = secondTypeCaptor2.getValue(); + + assertThat(firstTypeElements, hasSize(2)); + assertThat(secondTypeElements1, hasSize(1)); + assertThat(secondTypeElements2, hasSize(1)); + } + + @Test + public void testFileAddedBeforeListeners() throws IOException { + Files.copy(SOURCE_PATH.resolve("modelFileAddedOrRemoved.yaml"), fullModelPath); + YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock); + + modelRepository.processWatchEvent(WatchService.Kind.CREATE, MODEL_PATH); + + modelRepository.addYamlModelListener(firstTypeListener); + modelRepository.addYamlModelListener(secondTypeListener1); + modelRepository.addYamlModelListener(secondTypeListener2); + + verify(firstTypeListener).addedModel(eq(MODEL_NAME), firstTypeCaptor.capture()); + verify(firstTypeListener, never()).updatedModel(any(), any()); + verify(firstTypeListener, never()).removedModel(any(), any()); + verify(secondTypeListener1).addedModel(eq(MODEL_NAME), secondTypeCaptor1.capture()); + verify(secondTypeListener1, never()).updatedModel(any(), any()); + verify(secondTypeListener1, never()).removedModel(any(), any()); + verify(secondTypeListener2).addedModel(eq(MODEL_NAME), secondTypeCaptor2.capture()); + verify(secondTypeListener2, never()).updatedModel(any(), any()); + verify(secondTypeListener2, never()).removedModel(any(), any()); + + Collection firstTypeElements = firstTypeCaptor.getValue(); + Collection secondTypeElements1 = secondTypeCaptor1.getValue(); + Collection secondTypeElements2 = secondTypeCaptor2.getValue(); + + assertThat(firstTypeElements, + containsInAnyOrder(new FirstTypeDTO("First1", "Description1"), new FirstTypeDTO("First2", null))); + assertThat(secondTypeElements1, contains(new SecondTypeDTO("Second1", "Label1"))); + assertThat(secondTypeElements1, contains(new SecondTypeDTO("Second1", "Label1"))); + } + + @Test + public void testFileUpdated() throws IOException { + YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock); + modelRepository.addYamlModelListener(firstTypeListener); + + Files.copy(SOURCE_PATH.resolve("modelFileUpdatePost.yaml"), fullModelPath); + modelRepository.processWatchEvent(WatchService.Kind.CREATE, MODEL_PATH); + verify(firstTypeListener).addedModel(eq(MODEL_NAME), any()); + + Files.copy(SOURCE_PATH.resolve("modelFileUpdatePre.yaml"), fullModelPath, StandardCopyOption.REPLACE_EXISTING); + modelRepository.processWatchEvent(WatchService.Kind.MODIFY, MODEL_PATH); + verify(firstTypeListener, times(2)).addedModel(eq(MODEL_NAME), firstTypeCaptor.capture()); + verify(firstTypeListener).updatedModel(eq(MODEL_NAME), firstTypeCaptor.capture()); + verify(firstTypeListener).removedModel(eq(MODEL_NAME), firstTypeCaptor.capture()); + + List> arguments = firstTypeCaptor.getAllValues(); + assertThat(arguments, hasSize(4)); + + // added originally + assertThat(arguments.get(0), containsInAnyOrder(new FirstTypeDTO("First", "First original"), + new FirstTypeDTO("Second", "Second original"), new FirstTypeDTO("Third", "Third original"))); + // added by update + assertThat(arguments.get(1), contains(new FirstTypeDTO("Fourth", "Fourth original"))); + // updated by update + assertThat(arguments.get(2), contains(new FirstTypeDTO("Second", "Second modified"))); + // removed by update + assertThat(arguments.get(3), contains(new FirstTypeDTO("Third", "Third original"))); + } + + @Test + public void testFileRemoved() throws IOException { + YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock); + + modelRepository.addYamlModelListener(firstTypeListener); + + Files.copy(SOURCE_PATH.resolve("modelFileUpdatePost.yaml"), fullModelPath); + modelRepository.processWatchEvent(WatchService.Kind.CREATE, MODEL_PATH); + modelRepository.processWatchEvent(WatchService.Kind.DELETE, MODEL_PATH); + + verify(firstTypeListener).addedModel(eq(MODEL_NAME), firstTypeCaptor.capture()); + verify(firstTypeListener, never()).updatedModel(any(), any()); + verify(firstTypeListener).removedModel(eq(MODEL_NAME), firstTypeCaptor.capture()); + + List> arguments = firstTypeCaptor.getAllValues(); + assertThat(arguments, hasSize(2)); + + // all are added + assertThat(arguments.get(0), containsInAnyOrder(new FirstTypeDTO("First", "First original"), + new FirstTypeDTO("Second", "Second original"), new FirstTypeDTO("Third", "Third original"))); + // all are removed + assertThat(arguments.get(0), containsInAnyOrder(new FirstTypeDTO("First", "First original"), + new FirstTypeDTO("Second", "Second original"), new FirstTypeDTO("Third", "Third original"))); + } + + @Test + public void testAddElementToModel() throws IOException { + Files.copy(SOURCE_PATH.resolve("modifyModelInitialContent.yaml"), fullModelPath); + + YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock); + modelRepository.processWatchEvent(WatchService.Kind.CREATE, MODEL_PATH); + + FirstTypeDTO added = new FirstTypeDTO("element3", "description3"); + modelRepository.addElementToModel(MODEL_NAME, added); + + String actualFileContent = Files.readString(fullModelPath); + String expectedFileContent = Files.readString(SOURCE_PATH.resolve("addToModelExpectedContent.yaml")); + + assertThat(actualFileContent, is(expectedFileContent)); + } + + @Test + public void testUpdateElementInModel() throws IOException { + Files.copy(SOURCE_PATH.resolve("modifyModelInitialContent.yaml"), fullModelPath); + + YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock); + modelRepository.processWatchEvent(WatchService.Kind.CREATE, MODEL_PATH); + + FirstTypeDTO updated = new FirstTypeDTO("element1", "newDescription1"); + modelRepository.updateElementInModel(MODEL_NAME, updated); + + String actualFileContent = Files.readString(fullModelPath); + String expectedFileContent = Files.readString(SOURCE_PATH.resolve("updateInModelExpectedContent.yaml")); + + assertThat(actualFileContent, is(expectedFileContent)); + } + + @Test + public void testRemoveElementFromModel() throws IOException { + Files.copy(SOURCE_PATH.resolve("modifyModelInitialContent.yaml"), fullModelPath); + + YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock); + modelRepository.processWatchEvent(WatchService.Kind.CREATE, MODEL_PATH); + + FirstTypeDTO removed = new FirstTypeDTO("element1", "description1"); + modelRepository.removeElementFromModel(MODEL_NAME, removed); + + String actualFileContent = Files.readString(fullModelPath); + String expectedFileContent = Files.readString(SOURCE_PATH.resolve("removeFromModelExpectedContent.yaml")); + + assertThat(actualFileContent, is(expectedFileContent)); + } + + @Test + public void testReadOnlyModelNotUpdated() throws IOException { + Files.copy(SOURCE_PATH.resolve("modelFileAddedOrRemoved.yaml"), fullModelPath); + + YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock); + modelRepository.processWatchEvent(WatchService.Kind.CREATE, MODEL_PATH); + + FirstTypeDTO added = new FirstTypeDTO("element3", "description3"); + modelRepository.addElementToModel(MODEL_NAME, added); + + FirstTypeDTO removed = new FirstTypeDTO("element1", "description1"); + modelRepository.removeElementFromModel(MODEL_NAME, removed); + + FirstTypeDTO updated = new FirstTypeDTO("element2", "newDescription2"); + modelRepository.updateElementInModel(MODEL_NAME, updated); + + String actualFileContent = Files.readString(fullModelPath); + String expectedFileContent = Files.readString(SOURCE_PATH.resolve("modelFileAddedOrRemoved.yaml")); + + assertThat(actualFileContent, is(expectedFileContent)); + } +} diff --git a/bundles/org.openhab.core.model.yaml/src/test/java/org/openhab/core/model/yaml/test/FirstTypeDTO.java b/bundles/org.openhab.core.model.yaml/src/test/java/org/openhab/core/model/yaml/test/FirstTypeDTO.java new file mode 100644 index 00000000000..736effc0fe4 --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/test/java/org/openhab/core/model/yaml/test/FirstTypeDTO.java @@ -0,0 +1,63 @@ +/** + * 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.model.yaml.test; + +import java.util.Objects; + +import org.eclipse.jdt.annotation.NonNull; +import org.openhab.core.model.yaml.YamlElement; +import org.openhab.core.model.yaml.YamlElementName; + +/** + * The {@link FirstTypeDTO} is a test type implementing {@link YamlElement} + * + * @author Jan N. Klug - Initial contribution + */ +@YamlElementName("firstType") +public class FirstTypeDTO implements YamlElement { + public String uid; + public String description; + + public FirstTypeDTO() { + } + + public FirstTypeDTO(String uid, String description) { + this.uid = uid; + this.description = description; + } + + @Override + public @NonNull String getId() { + return uid; + } + + @Override + public boolean isValid() { + return uid != null; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + FirstTypeDTO that = (FirstTypeDTO) o; + return Objects.equals(uid, that.uid) && Objects.equals(description, that.description); + } + + @Override + public int hashCode() { + return Objects.hash(uid, description); + } +} diff --git a/bundles/org.openhab.core.model.yaml/src/test/java/org/openhab/core/model/yaml/test/SecondTypeDTO.java b/bundles/org.openhab.core.model.yaml/src/test/java/org/openhab/core/model/yaml/test/SecondTypeDTO.java new file mode 100644 index 00000000000..200980995e8 --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/test/java/org/openhab/core/model/yaml/test/SecondTypeDTO.java @@ -0,0 +1,63 @@ +/** + * 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.model.yaml.test; + +import java.util.Objects; + +import org.eclipse.jdt.annotation.NonNull; +import org.openhab.core.model.yaml.YamlElement; +import org.openhab.core.model.yaml.YamlElementName; + +/** + * The {@link SecondTypeDTO} is a test type implementing {@link YamlElement} + * + * @author Jan N. Klug - Initial contribution + */ +@YamlElementName("secondType") +public class SecondTypeDTO implements YamlElement { + public String id; + public String label; + + public SecondTypeDTO() { + } + + public SecondTypeDTO(String id, String label) { + this.id = id; + this.label = label; + } + + @Override + public @NonNull String getId() { + return id; + } + + @Override + public boolean isValid() { + return id != null; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + SecondTypeDTO that = (SecondTypeDTO) o; + return Objects.equals(id, that.id) && Objects.equals(label, that.label); + } + + @Override + public int hashCode() { + return Objects.hash(id, label); + } +} diff --git a/bundles/org.openhab.core.model.yaml/src/test/resources/addToModelExpectedContent.yaml b/bundles/org.openhab.core.model.yaml/src/test/resources/addToModelExpectedContent.yaml new file mode 100644 index 00000000000..1fbe75daf77 --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/test/resources/addToModelExpectedContent.yaml @@ -0,0 +1,9 @@ +version: 1 +readOnly: false +firstType: + - uid: element1 + description: description1 + - uid: element2 + description: description2 + - uid: element3 + description: description3 diff --git a/bundles/org.openhab.core.model.yaml/src/test/resources/modelFileAddedOrRemoved.yaml b/bundles/org.openhab.core.model.yaml/src/test/resources/modelFileAddedOrRemoved.yaml new file mode 100644 index 00000000000..2628f03bd52 --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/test/resources/modelFileAddedOrRemoved.yaml @@ -0,0 +1,28 @@ +# A YAML test file with different types +# The structure is valid but also contains invalid elements + +version: 1 + +# known first type +firstType: + # a valid element with uid and description + - uid: First1 + description: Description1 + + # a valid element with uid only + - uid: First2 + + # an invalid element (missing uid) + - description: Description3 + +# known second type +secondType: + # a valid element with id and label + - id: Second1 + label: Label1 + +# unknown third type +thirdType: + - foo: Bar + +nonArrayElement: Test diff --git a/bundles/org.openhab.core.model.yaml/src/test/resources/modelFileUpdatePost.yaml b/bundles/org.openhab.core.model.yaml/src/test/resources/modelFileUpdatePost.yaml new file mode 100644 index 00000000000..4648c250e63 --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/test/resources/modelFileUpdatePost.yaml @@ -0,0 +1,11 @@ +# A YAML test file for updating the model + +version: 1 + +firstType: + - uid: First + description: First original + - uid: Second + description: Second original + - uid: Third + description: Third original diff --git a/bundles/org.openhab.core.model.yaml/src/test/resources/modelFileUpdatePre.yaml b/bundles/org.openhab.core.model.yaml/src/test/resources/modelFileUpdatePre.yaml new file mode 100644 index 00000000000..b183f120614 --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/test/resources/modelFileUpdatePre.yaml @@ -0,0 +1,11 @@ +# A YAML test file for updating the model + +version: 1 + +firstType: + - uid: First + description: First original + - uid: Second + description: Second modified + - uid: Fourth + description: Fourth original diff --git a/bundles/org.openhab.core.model.yaml/src/test/resources/modifyModelInitialContent.yaml b/bundles/org.openhab.core.model.yaml/src/test/resources/modifyModelInitialContent.yaml new file mode 100644 index 00000000000..9f3b85b89d7 --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/test/resources/modifyModelInitialContent.yaml @@ -0,0 +1,7 @@ +version: 1 +readOnly: false +firstType: + - uid: element1 + description: description1 + - uid: element2 + description: description2 diff --git a/bundles/org.openhab.core.model.yaml/src/test/resources/removeFromModelExpectedContent.yaml b/bundles/org.openhab.core.model.yaml/src/test/resources/removeFromModelExpectedContent.yaml new file mode 100644 index 00000000000..82d98b0b47c --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/test/resources/removeFromModelExpectedContent.yaml @@ -0,0 +1,5 @@ +version: 1 +readOnly: false +firstType: + - uid: element2 + description: description2 diff --git a/bundles/org.openhab.core.model.yaml/src/test/resources/updateInModelExpectedContent.yaml b/bundles/org.openhab.core.model.yaml/src/test/resources/updateInModelExpectedContent.yaml new file mode 100644 index 00000000000..bcbf1240a78 --- /dev/null +++ b/bundles/org.openhab.core.model.yaml/src/test/resources/updateInModelExpectedContent.yaml @@ -0,0 +1,7 @@ +version: 1 +readOnly: false +firstType: + - uid: element1 + description: newDescription1 + - uid: element2 + description: description2 diff --git a/bundles/org.openhab.core.persistence/pom.xml b/bundles/org.openhab.core.persistence/pom.xml index 062427ac6bd..8f57dd5569b 100644 --- a/bundles/org.openhab.core.persistence/pom.xml +++ b/bundles/org.openhab.core.persistence/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.persistence diff --git a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/FilterCriteria.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/FilterCriteria.java index 73964aadf21..17714c2cf22 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/FilterCriteria.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/FilterCriteria.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/HistoricItem.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/HistoricItem.java index a6c9bc24dd5..ff1ea858488 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/HistoricItem.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/HistoricItem.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/ModifiablePersistenceService.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/ModifiablePersistenceService.java index 920fde8d8fb..6948bc55fcf 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/ModifiablePersistenceService.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/ModifiablePersistenceService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/PersistenceItemConfiguration.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/PersistenceItemConfiguration.java index 36d462333d4..b1d4fa50ca8 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/PersistenceItemConfiguration.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/PersistenceItemConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/PersistenceItemInfo.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/PersistenceItemInfo.java index 16bd4961dc6..8649f8968ed 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/PersistenceItemInfo.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/PersistenceItemInfo.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/PersistenceManager.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/PersistenceManager.java new file mode 100644 index 00000000000..f23b69f1a68 --- /dev/null +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/PersistenceManager.java @@ -0,0 +1,29 @@ +/** + * 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.persistence; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.core.items.Item; +import org.openhab.core.persistence.internal.PersistenceManagerImpl; + +/** + * The {@link PersistenceManager} interface is used to communicate between external components (e.g. REST interface) + * that modify persisted data bypassing the {@link PersistenceManagerImpl}. This is required because forecast jobs might + * need an update when the persisted data changes. + * + * @author Jan N. Klug - Initial contribution + */ +@NonNullByDefault +public interface PersistenceManager { + void handleExternalPersistenceDataChange(PersistenceService persistenceService, Item item); +} diff --git a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/PersistenceService.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/PersistenceService.java index e857cbf1a7d..04b84c71033 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/PersistenceService.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/PersistenceService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/PersistenceServiceRegistry.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/PersistenceServiceRegistry.java index 0ec2bb4828c..50ac26302d9 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/PersistenceServiceRegistry.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/PersistenceServiceRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/QueryablePersistenceService.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/QueryablePersistenceService.java index f07bdcfec6f..4b917056e37 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/QueryablePersistenceService.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/QueryablePersistenceService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/config/PersistenceAllConfig.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/config/PersistenceAllConfig.java index 9d05c15f31c..0121abc78cb 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/config/PersistenceAllConfig.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/config/PersistenceAllConfig.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/config/PersistenceConfig.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/config/PersistenceConfig.java index 23fa9cf7287..0ef991b8648 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/config/PersistenceConfig.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/config/PersistenceConfig.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/config/PersistenceGroupConfig.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/config/PersistenceGroupConfig.java index 04c55435871..fec8a946d05 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/config/PersistenceGroupConfig.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/config/PersistenceGroupConfig.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/config/PersistenceItemConfig.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/config/PersistenceItemConfig.java index 2195affece4..f7f80f68227 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/config/PersistenceItemConfig.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/config/PersistenceItemConfig.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/dto/ItemHistoryDTO.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/ItemHistoryDTO.java index 0fc11460737..bf1ddfbce8d 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/ItemHistoryDTO.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/ItemHistoryDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceCronStrategyDTO.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceCronStrategyDTO.java index 50c098618c7..728e2808823 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceCronStrategyDTO.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceCronStrategyDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceFilterDTO.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceFilterDTO.java index 097e92204d7..5a2c3bed9b2 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceFilterDTO.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceFilterDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceItemConfigurationDTO.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceItemConfigurationDTO.java index e1b0e082e60..3d4687aa26d 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceItemConfigurationDTO.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceItemConfigurationDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceServiceConfigurationDTO.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceServiceConfigurationDTO.java index e4faa9ed20f..505ead797ea 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceServiceConfigurationDTO.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceServiceConfigurationDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceServiceDTO.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceServiceDTO.java index 5c4de4671d1..59da36f552d 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceServiceDTO.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceServiceDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceStrategyDTO.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceStrategyDTO.java index 67bc881c0f4..e517a152133 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceStrategyDTO.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/dto/PersistenceStrategyDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/extensions/PersistenceExtensions.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/extensions/PersistenceExtensions.java index a1d536c1d47..62909962d04 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/extensions/PersistenceExtensions.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/extensions/PersistenceExtensions.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceEqualsFilter.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceEqualsFilter.java index 45ccbc69c2b..8b9f2ffaa9b 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceEqualsFilter.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceEqualsFilter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 class PersistenceEqualsFilter extends PersistenceFilter { public PersistenceEqualsFilter(String name, Collection values, @Nullable Boolean inverted) { super(name); this.values = values; - this.inverted = (inverted == null) ? false : inverted; + this.inverted = inverted != null && inverted; } public Collection getValues() { diff --git a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceFilter.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceFilter.java index 8ee2c8559c2..b63b2e2af9f 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceFilter.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceFilter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceIncludeFilter.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceIncludeFilter.java index 2ca7fc36470..8ff78cc148b 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceIncludeFilter.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceIncludeFilter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -45,7 +45,7 @@ public PersistenceIncludeFilter(String name, BigDecimal lower, BigDecimal upper, this.lower = lower; this.upper = upper; this.unit = (unit == null) ? "" : unit; - this.inverted = (inverted == null) ? false : inverted; + this.inverted = inverted != null && inverted; } public BigDecimal getLower() { diff --git a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceThresholdFilter.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceThresholdFilter.java index b841c0548bb..8e33b993ee2 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceThresholdFilter.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceThresholdFilter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -53,7 +53,7 @@ public PersistenceThresholdFilter(String name, BigDecimal value, @Nullable Strin super(name); this.value = value; this.unit = (unit == null) ? "" : unit; - this.relative = (relative == null) ? false : relative; + this.relative = relative != null && relative; } public BigDecimal getValue() { diff --git a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceTimeFilter.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceTimeFilter.java index cec6c967744..b445a33d5c1 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceTimeFilter.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/filter/PersistenceTimeFilter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceManager.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceManagerImpl.java similarity index 94% rename from bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceManager.java rename to bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceManagerImpl.java index b34282fcfa1..e09678b3224 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceManager.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceManagerImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,6 +51,7 @@ import org.openhab.core.persistence.HistoricItem; import org.openhab.core.persistence.ModifiablePersistenceService; import org.openhab.core.persistence.PersistenceItemConfiguration; +import org.openhab.core.persistence.PersistenceManager; import org.openhab.core.persistence.PersistenceService; import org.openhab.core.persistence.QueryablePersistenceService; import org.openhab.core.persistence.config.PersistenceAllConfig; @@ -90,11 +91,11 @@ * @author Jan N. Klug - Refactored to use service configuration registry * @author Jan N. Klug - Added time series support */ -@Component(immediate = true) +@Component(immediate = true, service = PersistenceManager.class) @NonNullByDefault -public class PersistenceManager implements ItemRegistryChangeListener, StateChangeListener, ReadyTracker, - PersistenceServiceConfigurationRegistryChangeListener, TimeSeriesListener { - private final Logger logger = LoggerFactory.getLogger(PersistenceManager.class); +public class PersistenceManagerImpl implements ItemRegistryChangeListener, StateChangeListener, ReadyTracker, + PersistenceServiceConfigurationRegistryChangeListener, TimeSeriesListener, PersistenceManager { + private final Logger logger = LoggerFactory.getLogger(PersistenceManagerImpl.class); private final ReadyMarker marker = new ReadyMarker("persistence", "restore"); @@ -111,7 +112,7 @@ public class PersistenceManager implements ItemRegistryChangeListener, StateChan private final Map persistenceServiceContainers = new ConcurrentHashMap<>(); @Activate - public PersistenceManager(final @Reference CronScheduler cronScheduler, final @Reference Scheduler scheduler, + public PersistenceManagerImpl(final @Reference CronScheduler cronScheduler, final @Reference Scheduler scheduler, final @Reference ItemRegistry itemRegistry, final @Reference SafeCaller safeCaller, final @Reference ReadyService readyService, final @Reference PersistenceServiceConfigurationRegistry persistenceServiceConfigurationRegistry) { @@ -200,13 +201,13 @@ private boolean appliesToItem(PersistenceItemConfiguration itemConfig, Item item for (PersistenceConfig itemCfg : itemConfig.items()) { if (itemCfg instanceof PersistenceAllConfig) { return true; - } else if (itemCfg instanceof PersistenceItemConfig) { - if (item.getName().equals(((PersistenceItemConfig) itemCfg).getItem())) { + } else if (itemCfg instanceof PersistenceItemConfig persistenceItemConfig) { + if (item.getName().equals(persistenceItemConfig.getItem())) { return true; } - } else if (itemCfg instanceof PersistenceGroupConfig) { + } else if (itemCfg instanceof PersistenceGroupConfig persistenceGroupConfig) { try { - Item gItem = itemRegistry.getItem(((PersistenceGroupConfig) itemCfg).getGroup()); + Item gItem = itemRegistry.getItem(persistenceGroupConfig.getGroup()); if (gItem instanceof GroupItem gItem2 && gItem2.getAllMembers().contains(item)) { return true; } @@ -233,16 +234,16 @@ private Iterable getAllItems(PersistenceItemConfiguration config) { // otherwise, go through the detailed definitions Set items = new HashSet<>(); for (Object itemCfg : config.items()) { - if (itemCfg instanceof PersistenceItemConfig) { - String itemName = ((PersistenceItemConfig) itemCfg).getItem(); + if (itemCfg instanceof PersistenceItemConfig persistenceItemConfig) { + String itemName = persistenceItemConfig.getItem(); try { items.add(itemRegistry.getItem(itemName)); } catch (ItemNotFoundException e) { logger.debug("Item '{}' does not exist.", itemName); } } - if (itemCfg instanceof PersistenceGroupConfig) { - String groupName = ((PersistenceGroupConfig) itemCfg).getGroup(); + if (itemCfg instanceof PersistenceGroupConfig persistenceGroupConfig) { + String groupName = persistenceGroupConfig.getGroup(); try { Item gItem = itemRegistry.getItem(groupName); if (gItem instanceof GroupItem groupItem) { @@ -392,6 +393,14 @@ public void updated(PersistenceServiceConfiguration oldElement, PersistenceServi added(element); } + @Override + public void handleExternalPersistenceDataChange(PersistenceService persistenceService, Item item) { + persistenceServiceContainers.values().stream() + .filter(container -> container.persistenceService.equals(persistenceService) && container + .getMatchingConfigurations(FORECAST).anyMatch(itemConf -> appliesToItem(itemConf, item))) + .forEach(container -> container.scheduleNextPersistedForecastForItem(item.getName())); + } + private class PersistenceServiceContainer { private final PersistenceService persistenceService; private final Set> persistJobs = new HashSet<>(); @@ -498,7 +507,6 @@ public void addItem(Item item) { } if (getMatchingConfigurations(FORECAST).anyMatch(configuration -> appliesToItem(configuration, item))) { scheduleNextPersistedForecastForItem(item.getName()); - } } } @@ -535,9 +543,9 @@ private void restoreItemStateIfPossible(Item item) { // someone else already restored the state or a new state was set return; } - genericItem.removeStateChangeListener(PersistenceManager.this); + genericItem.removeStateChangeListener(PersistenceManagerImpl.this); genericItem.setState(historicItem.getState()); - genericItem.addStateChangeListener(PersistenceManager.this); + genericItem.addStateChangeListener(PersistenceManagerImpl.this); if (logger.isDebugEnabled()) { logger.debug("Restored item state from '{}' for item '{}' -> '{}'", DateTimeFormatter.ISO_ZONED_DATE_TIME.format(historicItem.getTimestamp()), item.getName(), diff --git a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceServiceConfigurationRegistryImpl.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceServiceConfigurationRegistryImpl.java index 69e4cc151fa..cf4504e6122 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceServiceConfigurationRegistryImpl.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceServiceConfigurationRegistryImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceServiceRegistryImpl.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceServiceRegistryImpl.java index 266c2249b9a..8b83bc50f6e 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceServiceRegistryImpl.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/internal/PersistenceServiceRegistryImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/registry/ManagedPersistenceServiceConfigurationProvider.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/ManagedPersistenceServiceConfigurationProvider.java index 4bbd84d9626..7a3c410750f 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/ManagedPersistenceServiceConfigurationProvider.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/ManagedPersistenceServiceConfigurationProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfiguration.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfiguration.java index 214d584a83d..c40b1502580 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfiguration.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfigurationDTOMapper.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfigurationDTOMapper.java index a20dbcc6d39..c075bed2af2 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfigurationDTOMapper.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfigurationDTOMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfigurationProvider.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfigurationProvider.java index 942097f0900..f4c8b89cd1c 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfigurationProvider.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfigurationProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfigurationRegistry.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfigurationRegistry.java index 5435f5b8559..536112d8c88 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfigurationRegistry.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfigurationRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,11 +14,12 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.common.registry.Registry; +import org.openhab.core.persistence.internal.PersistenceManagerImpl; /** * The {@link PersistenceServiceConfigurationRegistry} is the central place to store persistence service configurations. * Configurations are registered through {@link PersistenceServiceConfigurationProvider}. - * Because the {@link org.openhab.core.persistence.internal.PersistenceManager} implementation needs to listen to + * Because the {@link PersistenceManagerImpl} implementation needs to listen to * different registries, the {@link PersistenceServiceConfigurationRegistryChangeListener} can be used to add listeners * to this registry. * diff --git a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfigurationRegistryChangeListener.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfigurationRegistryChangeListener.java index 4acf4d6adf1..2c87eaa47ad 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfigurationRegistryChangeListener.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/registry/PersistenceServiceConfigurationRegistryChangeListener.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/strategy/PersistenceCronStrategy.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/strategy/PersistenceCronStrategy.java index ddb88a50506..61eba0f4759 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/strategy/PersistenceCronStrategy.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/strategy/PersistenceCronStrategy.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/main/java/org/openhab/core/persistence/strategy/PersistenceStrategy.java b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/strategy/PersistenceStrategy.java index 343615e8f8b..d9699825812 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/strategy/PersistenceStrategy.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/openhab/core/persistence/strategy/PersistenceStrategy.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/test/java/org/openhab/core/persistence/extensions/PersistenceExtensionsTest.java b/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/extensions/PersistenceExtensionsTest.java index df375db1650..0819f3f0fac 100644 --- a/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/extensions/PersistenceExtensionsTest.java +++ b/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/extensions/PersistenceExtensionsTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/test/java/org/openhab/core/persistence/extensions/TestCachedValuesPersistenceService.java b/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/extensions/TestCachedValuesPersistenceService.java index 27563dd7b7d..6c6f2f3fd41 100644 --- a/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/extensions/TestCachedValuesPersistenceService.java +++ b/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/extensions/TestCachedValuesPersistenceService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/test/java/org/openhab/core/persistence/extensions/TestPersistenceService.java b/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/extensions/TestPersistenceService.java index f497a542559..316d2547cf8 100644 --- a/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/extensions/TestPersistenceService.java +++ b/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/extensions/TestPersistenceService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -93,7 +93,7 @@ public ZonedDateTime getTimestamp() { @Override public State getState() { - return hours < 5 || hours > 10 ? OnOffType.ON : OnOffType.OFF; + return OnOffType.from(hours < 5 || hours > 10); } @Override diff --git a/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/filter/PersistenceEqualsFilterTest.java b/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/filter/PersistenceEqualsFilterTest.java index 6660cbe1cf9..265dbc10778 100644 --- a/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/filter/PersistenceEqualsFilterTest.java +++ b/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/filter/PersistenceEqualsFilterTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/test/java/org/openhab/core/persistence/filter/PersistenceIncludeFilterTest.java b/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/filter/PersistenceIncludeFilterTest.java index 3b823cc0afe..1dfdf376e78 100644 --- a/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/filter/PersistenceIncludeFilterTest.java +++ b/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/filter/PersistenceIncludeFilterTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/test/java/org/openhab/core/persistence/filter/PersistenceThresholdFilterTest.java b/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/filter/PersistenceThresholdFilterTest.java index e37e22c5030..428c6d850d2 100644 --- a/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/filter/PersistenceThresholdFilterTest.java +++ b/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/filter/PersistenceThresholdFilterTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/test/java/org/openhab/core/persistence/filter/PersistenceTimeFilterTest.java b/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/filter/PersistenceTimeFilterTest.java index 38b2879e729..b04c813bd6b 100644 --- a/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/filter/PersistenceTimeFilterTest.java +++ b/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/filter/PersistenceTimeFilterTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.persistence/src/test/java/org/openhab/core/persistence/internal/PersistenceManagerTest.java b/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/internal/PersistenceManagerTest.java index 59888597860..bfd6ab7890c 100644 --- a/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/internal/PersistenceManagerTest.java +++ b/bundles/org.openhab.core.persistence/src/test/java/org/openhab/core/persistence/internal/PersistenceManagerTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,6 +29,7 @@ import java.util.Objects; import java.util.Set; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.junit.jupiter.api.BeforeEach; @@ -78,7 +79,7 @@ import org.openhab.core.types.UnDefType; /** - * The {@link PersistenceManagerTest} contains tests for the {@link PersistenceManager} + * The {@link PersistenceManagerTest} contains tests for the {@link PersistenceManagerImpl} * * @author Jan N. Klug - Initial contribution */ @@ -125,7 +126,7 @@ public String getName() { private @NonNullByDefault({}) @Mock ScheduledCompletableFuture scheduledFutureMock; private @NonNullByDefault({}) @Mock ItemRegistry itemRegistryMock; private @NonNullByDefault({}) @Mock SafeCaller safeCallerMock; - private @NonNullByDefault({}) @Mock SafeCallerBuilder safeCallerBuilderMock; + private @NonNullByDefault({}) @Mock SafeCallerBuilder<@NonNull QueryablePersistenceService> safeCallerBuilderMock; private @NonNullByDefault({}) @Mock ReadyService readyServiceMock; private @NonNullByDefault({}) @Mock PersistenceServiceConfigurationRegistry persistenceServiceConfigurationRegistryMock; @@ -133,7 +134,7 @@ public String getName() { private @NonNullByDefault({}) @Mock QueryablePersistenceService queryablePersistenceServiceMock; private @NonNullByDefault({}) @Mock ModifiablePersistenceService modifiablePersistenceServiceMock; - private @NonNullByDefault({}) PersistenceManager manager; + private @NonNullByDefault({}) PersistenceManagerImpl manager; @BeforeEach public void setUp() throws ItemNotFoundException { @@ -155,7 +156,7 @@ public void setUp() throws ItemNotFoundException { when(queryablePersistenceServiceMock.query(any())).thenReturn(List.of(TEST_HISTORIC_ITEM)); when(modifiablePersistenceServiceMock.getId()).thenReturn(TEST_MODIFIABLE_PERSISTENCE_SERVICE_ID); - manager = new PersistenceManager(cronSchedulerMock, schedulerMock, itemRegistryMock, safeCallerMock, + manager = new PersistenceManagerImpl(cronSchedulerMock, schedulerMock, itemRegistryMock, safeCallerMock, readyServiceMock, persistenceServiceConfigurationRegistryMock); manager.addPersistenceService(persistenceServiceMock); manager.addPersistenceService(queryablePersistenceServiceMock); diff --git a/bundles/org.openhab.core.semantics/model/generateTagClasses.groovy b/bundles/org.openhab.core.semantics/model/generateTagClasses.groovy index 0012ff6be0b..beccadf8c2e 100755 --- a/bundles/org.openhab.core.semantics/model/generateTagClasses.groovy +++ b/bundles/org.openhab.core.semantics/model/generateTagClasses.groovy @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/pom.xml b/bundles/org.openhab.core.semantics/pom.xml index f737fed3136..30f409f0257 100644 --- a/bundles/org.openhab.core.semantics/pom.xml +++ b/bundles/org.openhab.core.semantics/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.semantics diff --git a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/Equipment.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/Equipment.java index 096093cfa31..8c023d0daac 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/Equipment.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/Equipment.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/main/java/org/openhab/core/semantics/Location.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/Location.java index cc5a890dfb3..20d557ff802 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/Location.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/Location.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/main/java/org/openhab/core/semantics/ManagedSemanticTagProvider.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/ManagedSemanticTagProvider.java index e0df89a68be..c81af8a3bc6 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/ManagedSemanticTagProvider.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/ManagedSemanticTagProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/main/java/org/openhab/core/semantics/Point.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/Point.java index 8971feb32ce..eb4bf823c7d 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/Point.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/Point.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/main/java/org/openhab/core/semantics/Property.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/Property.java index d119925c14d..8fc43a543c0 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/Property.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/Property.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/main/java/org/openhab/core/semantics/SemanticTag.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticTag.java index d1782911521..b876595ee53 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticTag.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticTag.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/main/java/org/openhab/core/semantics/SemanticTagImpl.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticTagImpl.java index 37c7cd0381d..4ddcad87e46 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticTagImpl.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticTagImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/main/java/org/openhab/core/semantics/SemanticTagProvider.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticTagProvider.java index 3d4c0a5a14f..3912d2fdf6c 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticTagProvider.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticTagProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/main/java/org/openhab/core/semantics/SemanticTagRegistry.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticTagRegistry.java index a009bf7f534..855058b536a 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticTagRegistry.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticTagRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/main/java/org/openhab/core/semantics/SemanticTags.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticTags.java index fecebc542ab..c1019ee8ab0 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticTags.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticTags.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/main/java/org/openhab/core/semantics/SemanticsPredicates.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticsPredicates.java index 51d932fab23..0a7ff8a53bd 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticsPredicates.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticsPredicates.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/main/java/org/openhab/core/semantics/SemanticsService.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticsService.java index df36cc33cd2..1a71b4b5bb8 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticsService.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/SemanticsService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/main/java/org/openhab/core/semantics/Tag.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/Tag.java index 3c4e3342f88..d1503a22f2c 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/Tag.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/Tag.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/main/java/org/openhab/core/semantics/dto/SemanticTagDTO.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/dto/SemanticTagDTO.java index db00e10f968..0d17c13763f 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/dto/SemanticTagDTO.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/dto/SemanticTagDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/main/java/org/openhab/core/semantics/dto/SemanticTagDTOMapper.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/dto/SemanticTagDTOMapper.java index 0987bb6e1d4..2329358584b 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/dto/SemanticTagDTOMapper.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/dto/SemanticTagDTOMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/main/java/org/openhab/core/semantics/internal/SemanticTagRegistryImpl.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/internal/SemanticTagRegistryImpl.java index 55a9d01151c..006bd61feaf 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/internal/SemanticTagRegistryImpl.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/internal/SemanticTagRegistryImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.objectweb.asm.ClassWriter; import org.objectweb.asm.Opcodes; import org.openhab.core.common.registry.AbstractRegistry; +import org.openhab.core.common.registry.Identifiable; import org.openhab.core.common.registry.Provider; import org.openhab.core.semantics.Equipment; import org.openhab.core.semantics.Location; @@ -133,7 +134,7 @@ public boolean canBeAdded(SemanticTag tag) { @Override public List getSubTree(SemanticTag tag) { - List ids = getAll().stream().map(t -> t.getUID()).filter(uid -> uid.startsWith(tag.getUID() + "_")) + List ids = getAll().stream().map(Identifiable::getUID).filter(uid -> uid.startsWith(tag.getUID() + "_")) .toList(); List tags = new ArrayList<>(); tags.add(tag); @@ -194,7 +195,7 @@ protected void onAddElement(SemanticTag tag) throws IllegalArgumentException { + "': only Equipment, Location, Point and Property are allowed as root tags."); } type = uid; - className = newTag.getClass().getName(); + className = newTag.getName(); } else { String name = uid.substring(lastSeparator + 1); String parentId = uid.substring(0, lastSeparator); @@ -251,7 +252,7 @@ protected void onRemoveElement(SemanticTag tag) { private void addTagSet(String tagId, Class tagSet) { logger.trace("addTagSet {}", tagId); String id = tagId; - while (id.indexOf("_") != -1) { + while (id.contains("_")) { SemanticTags.addTagSet(id, tagSet); id = id.substring(id.indexOf("_") + 1); } @@ -265,7 +266,7 @@ private void removeTagSet(String tagId) { return; } String id = tagId; - while (id.indexOf("_") != -1) { + while (id.contains("_")) { SemanticTags.removeTagSet(id, tagSet); id = id.substring(id.indexOf("_") + 1); } diff --git a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/internal/SemanticsMetadataProvider.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/internal/SemanticsMetadataProvider.java index 863594d15b8..662333ff14d 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/internal/SemanticsMetadataProvider.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/internal/SemanticsMetadataProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -22,6 +22,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.common.registry.AbstractProvider; +import org.openhab.core.common.registry.RegistryChangeListener; import org.openhab.core.items.GroupItem; import org.openhab.core.items.Item; import org.openhab.core.items.ItemRegistry; @@ -33,6 +34,7 @@ import org.openhab.core.semantics.Location; import org.openhab.core.semantics.Point; import org.openhab.core.semantics.Property; +import org.openhab.core.semantics.SemanticTag; import org.openhab.core.semantics.SemanticTagRegistry; import org.openhab.core.semantics.SemanticTags; import org.openhab.core.semantics.Tag; @@ -72,11 +74,16 @@ public class SemanticsMetadataProvider extends AbstractProvider private final Map semantics = new TreeMap<>(String::compareTo); private final ItemRegistry itemRegistry; + private final SemanticTagRegistry semanticTagRegistry; + + private SemanticTagRegistryChangeListener listener; @Activate public SemanticsMetadataProvider(final @Reference ItemRegistry itemRegistry, final @Reference SemanticTagRegistry semanticTagRegistry) { this.itemRegistry = itemRegistry; + this.semanticTagRegistry = semanticTagRegistry; + this.listener = new SemanticTagRegistryChangeListener(this); } @Activate @@ -86,10 +93,12 @@ protected void activate() { processItem(item); } itemRegistry.addRegistryChangeListener(this); + semanticTagRegistry.addRegistryChangeListener(listener); } @Deactivate protected void deactivate() { + semanticTagRegistry.removeRegistryChangeListener(listener); itemRegistry.removeRegistryChangeListener(this); semantics.clear(); } @@ -134,10 +143,10 @@ private void processItem(Item item, List parentItems) { for (Item memberItem : groupItem.getMembers()) { if (parentItems.contains(memberItem.getName())) { logger.error( - "Recursive group membership found: {} is both, a direct or indirect parent and a child of {}.", + "Recursive group membership found: {} is a member of {}, but it is also one of its ancestors.", memberItem.getName(), groupItem.getName()); } else { - processItem(memberItem, parentItems); + processItem(memberItem, new ArrayList<>(parentItems)); } } } @@ -280,4 +289,28 @@ public void removed(Item item) { public void updated(Item oldItem, Item item) { processItem(item); } + + private static class SemanticTagRegistryChangeListener implements RegistryChangeListener { + + private SemanticsMetadataProvider provider; + + public SemanticTagRegistryChangeListener(SemanticsMetadataProvider provider) { + this.provider = provider; + } + + @Override + public void added(SemanticTag element) { + provider.allItemsChanged(List.of()); + } + + @Override + public void removed(SemanticTag element) { + provider.allItemsChanged(List.of()); + } + + @Override + public void updated(SemanticTag oldElement, SemanticTag element) { + provider.allItemsChanged(List.of()); + } + } } diff --git a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/internal/SemanticsServiceImpl.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/internal/SemanticsServiceImpl.java index 61a27a40b43..4bb336b8035 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/internal/SemanticsServiceImpl.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/internal/SemanticsServiceImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/main/java/org/openhab/core/semantics/model/DefaultSemanticTagProvider.java b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/model/DefaultSemanticTagProvider.java index 177d0657e95..2419262da47 100644 --- a/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/model/DefaultSemanticTagProvider.java +++ b/bundles/org.openhab.core.semantics/src/main/java/org/openhab/core/semantics/model/DefaultSemanticTagProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/test/java/org/openhab/core/semantics/SemanticTagsTest.java b/bundles/org.openhab.core.semantics/src/test/java/org/openhab/core/semantics/SemanticTagsTest.java index d17c798ea25..84aee51ed5e 100644 --- a/bundles/org.openhab.core.semantics/src/test/java/org/openhab/core/semantics/SemanticTagsTest.java +++ b/bundles/org.openhab.core.semantics/src/test/java/org/openhab/core/semantics/SemanticTagsTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/test/java/org/openhab/core/semantics/SemanticsPredicatesTest.java b/bundles/org.openhab.core.semantics/src/test/java/org/openhab/core/semantics/SemanticsPredicatesTest.java index 947ecaca92f..f88141c2761 100644 --- a/bundles/org.openhab.core.semantics/src/test/java/org/openhab/core/semantics/SemanticsPredicatesTest.java +++ b/bundles/org.openhab.core.semantics/src/test/java/org/openhab/core/semantics/SemanticsPredicatesTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/test/java/org/openhab/core/semantics/internal/SemanticTagRegistryImplTest.java b/bundles/org.openhab.core.semantics/src/test/java/org/openhab/core/semantics/internal/SemanticTagRegistryImplTest.java index 80532c3d92c..4d6c81b17e2 100644 --- a/bundles/org.openhab.core.semantics/src/test/java/org/openhab/core/semantics/internal/SemanticTagRegistryImplTest.java +++ b/bundles/org.openhab.core.semantics/src/test/java/org/openhab/core/semantics/internal/SemanticTagRegistryImplTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.semantics/src/test/java/org/openhab/core/semantics/internal/SemanticsMetadataProviderTest.java b/bundles/org.openhab.core.semantics/src/test/java/org/openhab/core/semantics/internal/SemanticsMetadataProviderTest.java index 0c67b9ae283..684a791d3f5 100644 --- a/bundles/org.openhab.core.semantics/src/test/java/org/openhab/core/semantics/internal/SemanticsMetadataProviderTest.java +++ b/bundles/org.openhab.core.semantics/src/test/java/org/openhab/core/semantics/internal/SemanticsMetadataProviderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -183,7 +183,7 @@ public void testGroupItemAddedBeforeMemberItemAdded() { Metadata metadata = Objects.requireNonNull(getMetadata(item)); assertEquals("Equipment_Door", metadata.getValue()); - assertEquals(metadata.getConfiguration().get("hasLocation"), GROUP_ITEM_NAME); + assertEquals(GROUP_ITEM_NAME, metadata.getConfiguration().get("hasLocation")); } @Test @@ -208,7 +208,7 @@ public void testGroupItemAddedAfterMemberItemAdded() { Metadata metadata = Objects.requireNonNull(getMetadata(item)); assertEquals("Equipment_Door", oldMetadata.getValue()); - assertEquals(metadata.getConfiguration().get("hasLocation"), GROUP_ITEM_NAME); + assertEquals(GROUP_ITEM_NAME, metadata.getConfiguration().get("hasLocation")); } @Test @@ -228,7 +228,7 @@ public void testGroupItemRemovedAfterMemberItemAdded() { Metadata oldMetadata = Objects.requireNonNull(getMetadata(item)); assertEquals("Equipment_Door", oldMetadata.getValue()); - assertEquals(oldMetadata.getConfiguration().get("hasLocation"), GROUP_ITEM_NAME); + assertEquals(GROUP_ITEM_NAME, oldMetadata.getConfiguration().get("hasLocation")); when(itemRegistry.get(GROUP_ITEM_NAME)).thenReturn(null); @@ -250,7 +250,7 @@ public void testRecursiveGroupMembershipDoesNotResultInStackOverflowError() { assertDoesNotThrow(() -> semanticsMetadataProvider.added(groupItem1)); assertLogMessage(SemanticsMetadataProvider.class, LogLevel.ERROR, - "Recursive group membership found: group1 is both, a direct or indirect parent and a child of group2."); + "Recursive group membership found: group1 is a member of group2, but it is also one of its ancestors."); } @Test @@ -266,7 +266,7 @@ public void testIndirectRecursiveMembershipDoesNotThrowStackOverflowError() { assertDoesNotThrow(() -> semanticsMetadataProvider.added(groupItem1)); assertLogMessage(SemanticsMetadataProvider.class, LogLevel.ERROR, - "Recursive group membership found: group1 is both, a direct or indirect parent and a child of group3."); + "Recursive group membership found: group1 is a member of group3, but it is also one of its ancestors."); } @Test @@ -284,6 +284,21 @@ public void testDuplicateMembershipOfPlainItemsDoesNotTriggerWarning() { assertNoLogMessage(SemanticsMetadataProvider.class); } + @Test + public void testDuplicateMembershipOfGroupItemsDoesNotTriggerWarning() { + GroupItem groupItem1 = new GroupItem("group1"); + GroupItem groupItem2 = new GroupItem("group2"); + GroupItem groupItem3 = new GroupItem("group3"); + + groupItem1.addMember(groupItem2); + groupItem1.addMember(groupItem3); + groupItem2.addMember(groupItem3); + + semanticsMetadataProvider.added(groupItem1); + + assertNoLogMessage(SemanticsMetadataProvider.class); + } + private @Nullable Metadata getMetadata(Item item) { return semanticsMetadataProvider.getAll().stream() // .filter(metadata -> metadata.getUID().getItemName().equals(item.getName())) // diff --git a/bundles/org.openhab.core.semantics/src/test/java/org/openhab/core/semantics/internal/SemanticsServiceImplTest.java b/bundles/org.openhab.core.semantics/src/test/java/org/openhab/core/semantics/internal/SemanticsServiceImplTest.java index 4e95ba4044d..db3fa7a6ce6 100644 --- a/bundles/org.openhab.core.semantics/src/test/java/org/openhab/core/semantics/internal/SemanticsServiceImplTest.java +++ b/bundles/org.openhab.core.semantics/src/test/java/org/openhab/core/semantics/internal/SemanticsServiceImplTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.storage.json/pom.xml b/bundles/org.openhab.core.storage.json/pom.xml index 6cd641f7d31..e2db408df66 100644 --- a/bundles/org.openhab.core.storage.json/pom.xml +++ b/bundles/org.openhab.core.storage.json/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.storage.json diff --git a/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/InstantTypeAdapter.java b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/InstantTypeAdapter.java new file mode 100644 index 00000000000..a8eb48b7369 --- /dev/null +++ b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/InstantTypeAdapter.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.storage.json.internal; + +import java.lang.reflect.Type; +import java.time.Instant; +import java.time.format.DateTimeParseException; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +/** + * The {@link InstantTypeAdapter} implements serialization and deserialization of {@link Instant}. + * as formatted UTC strings. + * + * Deserialization supports milliseconds since epoch as well. + * + * @author Jacob Laursen - Initial contribution + */ +@NonNullByDefault +public class InstantTypeAdapter implements JsonSerializer, JsonDeserializer { + /** + * Converts an {@link Instant} to a formatted UTC string. + */ + @Override + public JsonElement serialize(Instant instant, Type typeOfSrc, JsonSerializationContext context) { + return new JsonPrimitive(instant.toString()); + } + + /** + * Converts a formatted UTC string to {@link Instant}. + * As fallback, milliseconds since epoch is supported as well. + */ + @Override + public @Nullable Instant deserialize(JsonElement element, Type arg1, JsonDeserializationContext arg2) + throws JsonParseException { + try { + return Instant.parse(element.getAsString()); + } catch (DateTimeParseException e) { + // Fallback to milliseconds since epoch for backwards compatibility. + return Instant.ofEpochMilli(element.getAsLong()); + } + } +} diff --git a/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/JsonStorage.java b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/JsonStorage.java index 1d127974ad6..983f588f107 100644 --- a/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/JsonStorage.java +++ b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/JsonStorage.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,19 +17,22 @@ import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; +import java.time.Instant; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.openhab.core.common.ThreadPoolManager; import org.openhab.core.config.core.Configuration; import org.openhab.core.config.core.ConfigurationDeserializer; import org.openhab.core.config.core.OrderingMapSerializer; @@ -60,6 +63,7 @@ * de-/serialization, keep json structures in map * @author Sami Salonen - ordered inner and outer serialization of Maps, * Sets and properties of Configuration + * @author Jörg Sautter - use a scheduled thread pool */ @NonNullByDefault public class JsonStorage implements Storage { @@ -75,8 +79,8 @@ public class JsonStorage implements Storage { private static final String BACKUP_EXTENSION = "backup"; private static final String SEPARATOR = "--"; - private final Timer commitTimer; - private @Nullable TimerTask commitTimerTask; + private final ScheduledExecutorService scheduledExecutorService; + private @Nullable ScheduledFuture commitScheduledFuture; private long deferredSince = 0; @@ -97,7 +101,7 @@ public JsonStorage(File file, @Nullable ClassLoader classLoader, int maxBackupFi this.maxBackupFiles = maxBackupFiles; this.writeDelay = writeDelay; this.maxDeferredPeriod = maxDeferredPeriod; - this.typeMigrators = typeMigrators.stream().collect(Collectors.toMap(e -> e.getOldType(), e -> e)); + this.typeMigrators = typeMigrators.stream().collect(Collectors.toMap(TypeMigrator::getOldType, e -> e)); this.internalMapper = new GsonBuilder() // .registerTypeHierarchyAdapter(Map.class, new OrderingMapSerializer())// @@ -109,10 +113,11 @@ public JsonStorage(File file, @Nullable ClassLoader classLoader, int maxBackupFi .registerTypeHierarchyAdapter(Map.class, new OrderingMapSerializer())// .registerTypeHierarchyAdapter(Set.class, new OrderingSetSerializer())// .registerTypeAdapter(Configuration.class, new ConfigurationDeserializer()) // + .registerTypeAdapter(Instant.class, new InstantTypeAdapter()) // .setPrettyPrinting() // .create(); - commitTimer = new Timer(); + scheduledExecutorService = ThreadPoolManager.getScheduledPool("JsonStorage"); Map inputMap = null; if (file.exists()) { @@ -333,11 +338,11 @@ private void writeDatabaseFile(File dataFile, String data) throws IOException { * require a read and write, and is thus slower). */ public synchronized void flush() { - // Stop any existing timer - TimerTask commitTimerTask = this.commitTimerTask; - if (commitTimerTask != null) { - commitTimerTask.cancel(); - this.commitTimerTask = null; + // Stop any existing scheduled commit + ScheduledFuture commitScheduledFuture = this.commitScheduledFuture; + if (commitScheduledFuture != null) { + commitScheduledFuture.cancel(false); + this.commitScheduledFuture = null; } if (dirty) { @@ -376,41 +381,29 @@ private void cleanupBackups() { } } - private class CommitTimerTask extends TimerTask { - @Override - public void run() { - // Save the database - flush(); - } - } - public synchronized void deferredCommit() { dirty = true; - // Stop any existing timer - TimerTask commitTimerTask = this.commitTimerTask; - if (commitTimerTask != null) { - commitTimerTask.cancel(); - this.commitTimerTask = null; + // Stop any existing scheduled commit + ScheduledFuture commitScheduledFuture = this.commitScheduledFuture; + if (commitScheduledFuture != null) { + commitScheduledFuture.cancel(false); + this.commitScheduledFuture = null; } // Handle a maximum time for deferring the commit. // This stops a pathological loop preventing saving - if (deferredSince != 0 && deferredSince < System.nanoTime() - (maxDeferredPeriod * 1000L)) { + if (deferredSince != 0 && deferredSince < System.currentTimeMillis() - maxDeferredPeriod) { flush(); - // as we committed the database now, there is no need to start a new commit - // timer + // as we committed the database now, there is no need to schedule a new commit return; } if (deferredSince == 0) { - deferredSince = System.nanoTime(); + deferredSince = System.currentTimeMillis(); } - // Create the timer task - commitTimerTask = new CommitTimerTask(); - - // Start the timer - commitTimer.schedule(commitTimerTask, writeDelay); + // Schedule the commit + this.commitScheduledFuture = scheduledExecutorService.schedule(this::flush, writeDelay, TimeUnit.MILLISECONDS); } } diff --git a/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/JsonStorageService.java b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/JsonStorageService.java index 51ec5ba100e..94b69f7389c 100644 --- a/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/JsonStorageService.java +++ b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/JsonStorageService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.storage.json/src/main/java/org/openhab/core/storage/json/internal/StorageEntry.java b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/StorageEntry.java index c479f7b6546..d6e157c4495 100644 --- a/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/StorageEntry.java +++ b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/StorageEntry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.storage.json/src/main/java/org/openhab/core/storage/json/internal/StorageEntryMapDeserializer.java b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/StorageEntryMapDeserializer.java index a817653b016..eba92b7e666 100644 --- a/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/StorageEntryMapDeserializer.java +++ b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/StorageEntryMapDeserializer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -60,7 +60,7 @@ private boolean isOuterMap(JsonObject obj) { if (entrySet.size() != 2) { return false; } - Set keys = entrySet.stream().map(e -> e.getKey()).collect(Collectors.toSet()); + Set keys = entrySet.stream().map(Entry::getKey).collect(Collectors.toSet()); if (!keys.contains(JsonStorage.CLASS) || !keys.contains(JsonStorage.VALUE)) { return false; } diff --git a/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/BridgeImplTypeMigrator.java b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/BridgeImplTypeMigrator.java index 08e2ce5fa63..1361130a039 100644 --- a/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/BridgeImplTypeMigrator.java +++ b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/BridgeImplTypeMigrator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/PersistedTransformationTypeMigrator.java b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/PersistedTransformationTypeMigrator.java index 0efe9618b05..d894c334749 100644 --- a/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/PersistedTransformationTypeMigrator.java +++ b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/PersistedTransformationTypeMigrator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/RenamingTypeMigrator.java b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/RenamingTypeMigrator.java index 5f66ce9456b..51eeb4847f1 100644 --- a/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/RenamingTypeMigrator.java +++ b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/RenamingTypeMigrator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/ThingImplTypeMigrator.java b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/ThingImplTypeMigrator.java index 8fa82ac679f..11b145815d3 100644 --- a/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/ThingImplTypeMigrator.java +++ b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/ThingImplTypeMigrator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/TypeMigrationException.java b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/TypeMigrationException.java index 3ba9d65d5f1..7635cc03f25 100644 --- a/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/TypeMigrationException.java +++ b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/TypeMigrationException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/TypeMigrator.java b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/TypeMigrator.java index 92812130f49..be34ab5d326 100644 --- a/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/TypeMigrator.java +++ b/bundles/org.openhab.core.storage.json/src/main/java/org/openhab/core/storage/json/internal/migration/TypeMigrator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.storage.json/src/test/java/org/openhab/core/storage/json/internal/JsonStorageTest.java b/bundles/org.openhab.core.storage.json/src/test/java/org/openhab/core/storage/json/internal/JsonStorageTest.java index ad21e9d8817..5491294c0ff 100644 --- a/bundles/org.openhab.core.storage.json/src/test/java/org/openhab/core/storage/json/internal/JsonStorageTest.java +++ b/bundles/org.openhab.core.storage.json/src/test/java/org/openhab/core/storage/json/internal/JsonStorageTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -74,14 +74,14 @@ public void allInsertedNumbersAreLoadedAsBigDecimalFromCache() { DummyObject dummy = objectStorage.get("DummyObject"); assertNotNull(dummy); - assertTrue(dummy.configuration.get("testShort") instanceof BigDecimal); - assertTrue(dummy.configuration.get("testInt") instanceof BigDecimal); - assertTrue(dummy.configuration.get("testLong") instanceof BigDecimal); - assertTrue(dummy.configuration.get("testDouble") instanceof BigDecimal); - assertTrue(dummy.configuration.get("testFloat") instanceof BigDecimal); - assertTrue(dummy.configuration.get("testBigDecimal") instanceof BigDecimal); - assertTrue(dummy.configuration.get("testBoolean") instanceof Boolean); - assertTrue(dummy.configuration.get("testString") instanceof String); + assertInstanceOf(BigDecimal.class, dummy.configuration.get("testShort")); + assertInstanceOf(BigDecimal.class, dummy.configuration.get("testInt")); + assertInstanceOf(BigDecimal.class, dummy.configuration.get("testLong")); + assertInstanceOf(BigDecimal.class, dummy.configuration.get("testDouble")); + assertInstanceOf(BigDecimal.class, dummy.configuration.get("testFloat")); + assertInstanceOf(BigDecimal.class, dummy.configuration.get("testBigDecimal")); + assertInstanceOf(Boolean.class, dummy.configuration.get("testBoolean")); + assertInstanceOf(String.class, dummy.configuration.get("testString")); } @Test @@ -91,14 +91,14 @@ public void allInsertedNumbersAreLoadedAsBigDecimalFromDisk() { DummyObject dummy = objectStorage.get("DummyObject"); assertNotNull(dummy); - assertTrue(dummy.configuration.get("testShort") instanceof BigDecimal); - assertTrue(dummy.configuration.get("testInt") instanceof BigDecimal); - assertTrue(dummy.configuration.get("testLong") instanceof BigDecimal); - assertTrue(dummy.configuration.get("testDouble") instanceof BigDecimal); - assertTrue(dummy.configuration.get("testFloat") instanceof BigDecimal); - assertTrue(dummy.configuration.get("testBigDecimal") instanceof BigDecimal); - assertTrue(dummy.configuration.get("testBoolean") instanceof Boolean); - assertTrue(dummy.configuration.get("testString") instanceof String); + assertInstanceOf(BigDecimal.class, dummy.configuration.get("testShort")); + assertInstanceOf(BigDecimal.class, dummy.configuration.get("testInt")); + assertInstanceOf(BigDecimal.class, dummy.configuration.get("testLong")); + assertInstanceOf(BigDecimal.class, dummy.configuration.get("testDouble")); + assertInstanceOf(BigDecimal.class, dummy.configuration.get("testFloat")); + assertInstanceOf(BigDecimal.class, dummy.configuration.get("testBigDecimal")); + assertInstanceOf(Boolean.class, dummy.configuration.get("testBoolean")); + assertInstanceOf(String.class, dummy.configuration.get("testString")); } @Test @@ -107,10 +107,10 @@ public void testIntegerScaleFromCache() { DummyObject dummy = objectStorage.get("DummyObject"); assertNotNull(dummy); - assertEquals(((BigDecimal) dummy.configuration.get("testShort")).scale(), 0); - assertEquals(((BigDecimal) dummy.configuration.get("testInt")).scale(), 0); - assertEquals(((BigDecimal) dummy.configuration.get("testLong")).scale(), 0); - assertEquals(((BigDecimal) dummy.configuration.get("testBigDecimal")).scale(), 0); + assertEquals(0, ((BigDecimal) dummy.configuration.get("testShort")).scale()); + assertEquals(0, ((BigDecimal) dummy.configuration.get("testInt")).scale()); + assertEquals(0, ((BigDecimal) dummy.configuration.get("testLong")).scale()); + assertEquals(0, ((BigDecimal) dummy.configuration.get("testBigDecimal")).scale()); } @SuppressWarnings("unchecked") @@ -121,14 +121,14 @@ public void testIntegerScaleFromDisk() { DummyObject dummy = objectStorage.get("DummyObject"); assertNotNull(dummy); - assertEquals(((BigDecimal) dummy.configuration.get("testShort")).scale(), 0); - assertEquals(((BigDecimal) dummy.configuration.get("testInt")).scale(), 0); - assertEquals(((BigDecimal) dummy.configuration.get("testLong")).scale(), 0); - assertEquals(((BigDecimal) dummy.configuration.get("testBigDecimal")).scale(), 0); - assertEquals(((List) dummy.configuration.get("multiInt")).get(0).scale(), 0); - assertEquals(((List) dummy.configuration.get("multiInt")).get(1).scale(), 0); - assertEquals(((List) dummy.configuration.get("multiInt")).get(2).scale(), 0); - assertEquals(((BigDecimal) dummy.channels.get(0).configuration.get("testChildLong")).scale(), 0); + assertEquals(0, ((BigDecimal) dummy.configuration.get("testShort")).scale()); + assertEquals(0, ((BigDecimal) dummy.configuration.get("testInt")).scale()); + assertEquals(0, ((BigDecimal) dummy.configuration.get("testLong")).scale()); + assertEquals(0, ((BigDecimal) dummy.configuration.get("testBigDecimal")).scale()); + assertEquals(0, ((List) dummy.configuration.get("multiInt")).get(0).scale()); + assertEquals(0, ((List) dummy.configuration.get("multiInt")).get(1).scale()); + assertEquals(0, ((List) dummy.configuration.get("multiInt")).get(2).scale()); + assertEquals(0, ((BigDecimal) dummy.channels.get(0).configuration.get("testChildLong")).scale()); } @Test diff --git a/bundles/org.openhab.core.storage.json/src/test/java/org/openhab/core/storage/json/internal/MigrationTest.java b/bundles/org.openhab.core.storage.json/src/test/java/org/openhab/core/storage/json/internal/MigrationTest.java index cd24b2ced7f..cd45a1f4634 100644 --- a/bundles/org.openhab.core.storage.json/src/test/java/org/openhab/core/storage/json/internal/MigrationTest.java +++ b/bundles/org.openhab.core.storage.json/src/test/java/org/openhab/core/storage/json/internal/MigrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.storage.json/src/test/java/org/openhab/core/storage/json/internal/PersistedTransformationMigratorTest.java b/bundles/org.openhab.core.storage.json/src/test/java/org/openhab/core/storage/json/internal/PersistedTransformationMigratorTest.java index 4cc2a6c7f14..1b8ea516cc8 100644 --- a/bundles/org.openhab.core.storage.json/src/test/java/org/openhab/core/storage/json/internal/PersistedTransformationMigratorTest.java +++ b/bundles/org.openhab.core.storage.json/src/test/java/org/openhab/core/storage/json/internal/PersistedTransformationMigratorTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.storage.json/src/test/java/org/openhab/core/storage/json/internal/ThingStorageEntityMigratorTest.java b/bundles/org.openhab.core.storage.json/src/test/java/org/openhab/core/storage/json/internal/ThingStorageEntityMigratorTest.java index 27809eb6f01..0326c9d907d 100644 --- a/bundles/org.openhab.core.storage.json/src/test/java/org/openhab/core/storage/json/internal/ThingStorageEntityMigratorTest.java +++ b/bundles/org.openhab.core.storage.json/src/test/java/org/openhab/core/storage/json/internal/ThingStorageEntityMigratorTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/pom.xml b/bundles/org.openhab.core.test.magic/pom.xml index 9fa196648c5..d5cc915de27 100644 --- a/bundles/org.openhab.core.test.magic/pom.xml +++ b/bundles/org.openhab.core.test.magic/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.test.magic diff --git a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/MagicBindingConstants.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/MagicBindingConstants.java index 47d1981b099..d86b30058af 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/MagicBindingConstants.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/MagicBindingConstants.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/MagicService.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/MagicService.java index 758f33187bd..24d8ebb3835 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/MagicService.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/MagicService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,5 +25,5 @@ @NonNullByDefault public interface MagicService extends ConfigOptionProvider { - static final URI CONFIG_URI = URI.create("test:magic"); + URI CONFIG_URI = URI.create("test:magic"); } diff --git a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicActionModuleThingHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicActionModuleThingHandler.java index 499884e20d1..3f264a96b50 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicActionModuleThingHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicActionModuleThingHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicBridgeHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicBridgeHandler.java index e0e7f819dbc..4c6ce5f1244 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicBridgeHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicBridgeHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicBridgedThingHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicBridgedThingHandler.java index 36cc40eb579..7c51d29dcab 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicBridgedThingHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicBridgedThingHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicButtonHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicButtonHandler.java index eb48efb4dde..97a8a94ddc6 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicButtonHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicButtonHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicChattyThingHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicChattyThingHandler.java index ed36e713eda..8610eaa9254 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicChattyThingHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicChattyThingHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicColorLightHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicColorLightHandler.java index 344a2379394..81f2a2a00a5 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicColorLightHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicColorLightHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicConfigurableThingHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicConfigurableThingHandler.java index 6e0523ee29c..017a74b9bfc 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicConfigurableThingHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicConfigurableThingHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicContactHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicContactHandler.java index 8f9f366ad81..ed9c4bb2caa 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicContactHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicContactHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicDelayedOnlineHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicDelayedOnlineHandler.java index 6bb90d6d6e2..ca824ad169a 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicDelayedOnlineHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicDelayedOnlineHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicDimmableLightHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicDimmableLightHandler.java index 8bd5d382168..4bae84d201e 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicDimmableLightHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicDimmableLightHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicDynamicStateDescriptionThingHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicDynamicStateDescriptionThingHandler.java index 33114d838d8..4702cc5c0f2 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicDynamicStateDescriptionThingHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicDynamicStateDescriptionThingHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicExtensibleThingHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicExtensibleThingHandler.java index b407c0edfc7..0baed701fb7 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicExtensibleThingHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicExtensibleThingHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicFirmwareUpdateThingHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicFirmwareUpdateThingHandler.java index 08d4eaafcb0..0655eeac908 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicFirmwareUpdateThingHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicFirmwareUpdateThingHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicImageHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicImageHandler.java index 21bfe62a6fc..737e2152f9c 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicImageHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicImageHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicLocationThingHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicLocationThingHandler.java index e4a875f8f8c..99058e2cffd 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicLocationThingHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicLocationThingHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicOnOffLightHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicOnOffLightHandler.java index a7f562d2854..cc9a7c0be40 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicOnOffLightHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicOnOffLightHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicOnlineOfflineHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicOnlineOfflineHandler.java index eb9b8508eaa..68679be454d 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicOnlineOfflineHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicOnlineOfflineHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicPlayerHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicPlayerHandler.java index 534ba494b42..bbf8245fae7 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicPlayerHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicPlayerHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicRollershutterHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicRollershutterHandler.java index 6e00d8e7dc8..2d5dc3135b5 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicRollershutterHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicRollershutterHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicThermostatThingHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicThermostatThingHandler.java index eb112c642ea..4fb6218cd91 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicThermostatThingHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicThermostatThingHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicTimeSeriesHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicTimeSeriesHandler.java index a596a7719e2..1efb32267c1 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicTimeSeriesHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/handler/MagicTimeSeriesHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicDiscoveryService.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicDiscoveryService.java index 9928a3f3f10..b0c5b5e3d8f 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicDiscoveryService.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicDiscoveryService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicDynamicCommandDescriptionProvider.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicDynamicCommandDescriptionProvider.java index f2ab10ae2f7..ab9314f8bda 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicDynamicCommandDescriptionProvider.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicDynamicCommandDescriptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicDynamicStateDescriptionProvider.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicDynamicStateDescriptionProvider.java index d3c0cff9019..ebead368ee0 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicDynamicStateDescriptionProvider.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicDynamicStateDescriptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicHandlerFactory.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicHandlerFactory.java index b2ae4f9464d..75acd203d10 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicHandlerFactory.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicHandlerFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicServiceConfig.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicServiceConfig.java index 1e46d4bf392..2620f92140c 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicServiceConfig.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicServiceConfig.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicServiceImpl.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicServiceImpl.java index a67095b3f26..0a673c486ee 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicServiceImpl.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/MagicServiceImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/internal/automation/modules/MagicMultiActionMarker.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/automation/modules/MagicMultiActionMarker.java index 19ee855117b..a55ff1943cf 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/automation/modules/MagicMultiActionMarker.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/automation/modules/MagicMultiActionMarker.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/internal/automation/modules/MagicMultiServiceMultiActions.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/automation/modules/MagicMultiServiceMultiActions.java index 05cf1a9ef97..f6031b5aa47 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/automation/modules/MagicMultiServiceMultiActions.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/automation/modules/MagicMultiServiceMultiActions.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/internal/automation/modules/MagicSingleActionService.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/automation/modules/MagicSingleActionService.java index 38b1e279e64..174ba41fa68 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/automation/modules/MagicSingleActionService.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/automation/modules/MagicSingleActionService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/internal/automation/modules/MagicThingActionsService.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/automation/modules/MagicThingActionsService.java index f7a0fa956c3..2e48155e56c 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/automation/modules/MagicThingActionsService.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/automation/modules/MagicThingActionsService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/binding/internal/firmware/MagicFirmwareProvider.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/firmware/MagicFirmwareProvider.java index be7486e51ae..0cb55d1f7c6 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/firmware/MagicFirmwareProvider.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/binding/internal/firmware/MagicFirmwareProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/internal/metadata/MagicMetadataProvider.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/internal/metadata/MagicMetadataProvider.java index bcce9578d71..3b3bd2f0a52 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/internal/metadata/MagicMetadataProvider.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/internal/metadata/MagicMetadataProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/internal/metadata/MagicMetadataProvider2.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/internal/metadata/MagicMetadataProvider2.java index 18b3b512a5e..456f25a1dfb 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/internal/metadata/MagicMetadataProvider2.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/internal/metadata/MagicMetadataProvider2.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/internal/metadata/MagicMetadataUsingService.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/internal/metadata/MagicMetadataUsingService.java index f84e5386bb0..f585ec83300 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/internal/metadata/MagicMetadataUsingService.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/internal/metadata/MagicMetadataUsingService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/service/MagicMultiInstanceService.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/service/MagicMultiInstanceService.java index 90547af9e17..6f6fcd24e52 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/service/MagicMultiInstanceService.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/service/MagicMultiInstanceService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/main/java/org/openhab/core/magic/service/MagicMultiInstanceServiceMarker.java b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/service/MagicMultiInstanceServiceMarker.java index 014a0ce1bc9..ba690366b74 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/service/MagicMultiInstanceServiceMarker.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/openhab/core/magic/service/MagicMultiInstanceServiceMarker.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/test/java/org/openhab/core/magic/binding/handler/MagicColorLightHandlerTest.java b/bundles/org.openhab.core.test.magic/src/test/java/org/openhab/core/magic/binding/handler/MagicColorLightHandlerTest.java index ab875f393e4..01a5fafc38a 100644 --- a/bundles/org.openhab.core.test.magic/src/test/java/org/openhab/core/magic/binding/handler/MagicColorLightHandlerTest.java +++ b/bundles/org.openhab.core.test.magic/src/test/java/org/openhab/core/magic/binding/handler/MagicColorLightHandlerTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +31,7 @@ import org.openhab.core.thing.binding.ThingHandlerCallback; /** - * Tests cases for {@link MagicONOffLightHandler}. The tests provide mocks for supporting entities using Mockito. + * Tests cases for {@link MagicColorLightHandler}. The tests provide mocks for supporting entities using Mockito. * * @author Henning Treu - Initial contribution */ diff --git a/bundles/org.openhab.core.test.magic/src/test/java/org/openhab/core/magic/binding/handler/MagicDimmableLightHandlerTest.java b/bundles/org.openhab.core.test.magic/src/test/java/org/openhab/core/magic/binding/handler/MagicDimmableLightHandlerTest.java index 8095892797c..cf042312e38 100644 --- a/bundles/org.openhab.core.test.magic/src/test/java/org/openhab/core/magic/binding/handler/MagicDimmableLightHandlerTest.java +++ b/bundles/org.openhab.core.test.magic/src/test/java/org/openhab/core/magic/binding/handler/MagicDimmableLightHandlerTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/test/java/org/openhab/core/magic/binding/handler/MagicOnOffLightHandlerTest.java b/bundles/org.openhab.core.test.magic/src/test/java/org/openhab/core/magic/binding/handler/MagicOnOffLightHandlerTest.java index e3f7a7a4255..e3b09acf832 100644 --- a/bundles/org.openhab.core.test.magic/src/test/java/org/openhab/core/magic/binding/handler/MagicOnOffLightHandlerTest.java +++ b/bundles/org.openhab.core.test.magic/src/test/java/org/openhab/core/magic/binding/handler/MagicOnOffLightHandlerTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/test/java/org/openhab/core/magic/binding/internal/MagicHandlerFactoryTest.java b/bundles/org.openhab.core.test.magic/src/test/java/org/openhab/core/magic/binding/internal/MagicHandlerFactoryTest.java index 6ce22f304dd..a7f8137c318 100644 --- a/bundles/org.openhab.core.test.magic/src/test/java/org/openhab/core/magic/binding/internal/MagicHandlerFactoryTest.java +++ b/bundles/org.openhab.core.test.magic/src/test/java/org/openhab/core/magic/binding/internal/MagicHandlerFactoryTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test.magic/src/test/java/org/openhab/core/magic/binding/internal/MagicServiceImplTest.java b/bundles/org.openhab.core.test.magic/src/test/java/org/openhab/core/magic/binding/internal/MagicServiceImplTest.java index 0856d99bbb6..0e1f0f5af4b 100644 --- a/bundles/org.openhab.core.test.magic/src/test/java/org/openhab/core/magic/binding/internal/MagicServiceImplTest.java +++ b/bundles/org.openhab.core.test.magic/src/test/java/org/openhab/core/magic/binding/internal/MagicServiceImplTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test/pom.xml b/bundles/org.openhab.core.test/pom.xml index 5044410c21b..bd23910a93e 100644 --- a/bundles/org.openhab.core.test/pom.xml +++ b/bundles/org.openhab.core.test/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.test @@ -35,7 +35,7 @@ ch.qos.logback logback-classic - 1.3.11 + 1.3.14 compile diff --git a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/AsyncResultWrapper.java b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/AsyncResultWrapper.java index d881ded9c82..943e4f727d0 100644 --- a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/AsyncResultWrapper.java +++ b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/AsyncResultWrapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test/src/main/java/org/openhab/core/test/BundleCloseable.java b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/BundleCloseable.java index 788661dee73..1eaaaed4af2 100644 --- a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/BundleCloseable.java +++ b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/BundleCloseable.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test/src/main/java/org/openhab/core/test/SyntheticBundleInstaller.java b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/SyntheticBundleInstaller.java index ec97571e823..b8b375c1a95 100644 --- a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/SyntheticBundleInstaller.java +++ b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/SyntheticBundleInstaller.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test/src/main/java/org/openhab/core/test/TestPortUtil.java b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/TestPortUtil.java index 33c670cddfc..e30f52b1275 100644 --- a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/TestPortUtil.java +++ b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/TestPortUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test/src/main/java/org/openhab/core/test/TestServer.java b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/TestServer.java index 0fda8db4806..f22f1ce30df 100644 --- a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/TestServer.java +++ b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/TestServer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test/src/main/java/org/openhab/core/test/internal/java/MissingServiceAnalyzer.java b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/internal/java/MissingServiceAnalyzer.java index 48bd23e5025..c1dfb00975c 100644 --- a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/internal/java/MissingServiceAnalyzer.java +++ b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/internal/java/MissingServiceAnalyzer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test/src/main/java/org/openhab/core/test/java/JavaOSGiTest.java b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/java/JavaOSGiTest.java index 4cb76d754c7..d57a386fe27 100644 --- a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/java/JavaOSGiTest.java +++ b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/java/JavaOSGiTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Predicate; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -160,7 +161,7 @@ protected List getServices(Class clazz, Predicate> private ServiceReference @Nullable [] getServices(final Class clazz) { try { @SuppressWarnings("unchecked") - ServiceReference serviceReferences[] = (ServiceReference[]) bundleContext + ServiceReference[] serviceReferences = (ServiceReference[]) bundleContext .getServiceReferences(clazz.getName(), null); return serviceReferences; } catch (InvalidSyntaxException e) { @@ -264,11 +265,8 @@ protected ServiceRegistration registerService(final Object service, final Str } private void saveServiceRegistration(final String interfaceName, final ServiceRegistration srvReg) { - List> regs = registeredServices.get(interfaceName); - if (regs == null) { - regs = new ArrayList<>(); - registeredServices.put(interfaceName, regs); - } + List> regs = Objects + .requireNonNull(registeredServices.computeIfAbsent(interfaceName, k -> new ArrayList<>())); regs.add(srvReg); } diff --git a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/java/JavaTest.java b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/java/JavaTest.java index 5bd878314c5..ff22c06fd2a 100644 --- a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/java/JavaTest.java +++ b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/java/JavaTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test/src/main/java/org/openhab/core/test/storage/VolatileStorage.java b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/storage/VolatileStorage.java index 4c206a89fd9..905609f2f2d 100644 --- a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/storage/VolatileStorage.java +++ b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/storage/VolatileStorage.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test/src/main/java/org/openhab/core/test/storage/VolatileStorageService.java b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/storage/VolatileStorageService.java index bcd4ed50384..47de4083aa0 100644 --- a/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/storage/VolatileStorageService.java +++ b/bundles/org.openhab.core.test/src/main/java/org/openhab/core/test/storage/VolatileStorageService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.test/src/test/java/org/openhab/core/test/java/JavaTestTest.java b/bundles/org.openhab.core.test/src/test/java/org/openhab/core/test/java/JavaTestTest.java index 1575fbb2ad7..8aacec5c7d5 100644 --- a/bundles/org.openhab.core.test/src/test/java/org/openhab/core/test/java/JavaTestTest.java +++ b/bundles/org.openhab.core.test/src/test/java/org/openhab/core/test/java/JavaTestTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +50,7 @@ public void waitForAssertShouldRunAfterLastCallWhenAssertionSucceeds() { public void waitForAssertShouldRunAfterLastCallWhenAssertionFails() { Runnable afterLastCall = mock(Runnable.class); try { - javaTest.waitForAssert(() -> assertTrue(false), null, afterLastCall, 100, 50); + javaTest.waitForAssert(() -> fail(), null, afterLastCall, 100, 50); } catch (final AssertionError ex) { } verify(afterLastCall, times(1)).run(); diff --git a/bundles/org.openhab.core.thing/pom.xml b/bundles/org.openhab.core.thing/pom.xml index 77491668103..12cf68adbed 100644 --- a/bundles/org.openhab.core.thing/pom.xml +++ b/bundles/org.openhab.core.thing/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.thing diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/Bridge.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/Bridge.java index 62895cb0eb9..97b2bdd56d3 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/Bridge.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/Bridge.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -22,7 +22,7 @@ * A {@link Bridge} is a {@link Thing} that connects other {@link Thing}s. * * @author Dennis Nobel - Initial contribution - * @author Christoph Weitkamp - Added method `getThing(ThingUID)` + * @author Christoph Weitkamp - Added method {@code getThing(ThingUID)} */ @NonNullByDefault public interface Bridge extends Thing { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/Channel.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/Channel.java index ee1e8c9a001..d3b4c919c01 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/Channel.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/Channel.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/ChannelGroupUID.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ChannelGroupUID.java index 70c85ed545b..636457428f4 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ChannelGroupUID.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ChannelGroupUID.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/ChannelUID.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ChannelUID.java index 7e50b307826..0b833f30426 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ChannelUID.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ChannelUID.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +25,7 @@ * @author Jochen Hiller - Bugfix 455434: added default constructor * @author Dennis Nobel - Added channel group id * @author Kai Kreuzer - Changed creation of channels to not require a thing type - * @author Christoph Weitkamp - Changed pattern for validating last segment to contain either a single `#` or none + * @author Christoph Weitkamp - Changed pattern for validating last segment to contain either a single {@code #} or none */ @NonNullByDefault public class ChannelUID extends UID { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/CommonTriggerEvents.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/CommonTriggerEvents.java index 0b4f0b29a04..9825a8063d6 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/CommonTriggerEvents.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/CommonTriggerEvents.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/DefaultSystemChannelTypeProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/DefaultSystemChannelTypeProvider.java index c637989365a..1fb5c9b0f51 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/DefaultSystemChannelTypeProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/DefaultSystemChannelTypeProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/ManagedThingProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ManagedThingProvider.java index 596a8361829..f981ffeacfe 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ManagedThingProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ManagedThingProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/Thing.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/Thing.java index a17e7c41946..7399ee8a4a8 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/Thing.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/Thing.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,28 +34,28 @@ * @author Simon Kaufmann - Added label, location * @author Kai Kreuzer - Removed linked items from Thing * @author Yordan Zhelev - Added method for getting the enabled status - * @author Christoph Weitkamp - Added method `getChannel(ChannelUID)` + * @author Christoph Weitkamp - Added method {@code getChannel(ChannelUID)} */ @NonNullByDefault public interface Thing extends Identifiable { /** the key for the vendor property */ - final String PROPERTY_VENDOR = "vendor"; + String PROPERTY_VENDOR = "vendor"; /** the key for the model ID property */ - final String PROPERTY_MODEL_ID = "modelId"; + String PROPERTY_MODEL_ID = "modelId"; /** the key for the serial number property */ - final String PROPERTY_SERIAL_NUMBER = "serialNumber"; + String PROPERTY_SERIAL_NUMBER = "serialNumber"; /** the key for the hardware version property */ - final String PROPERTY_HARDWARE_VERSION = "hardwareVersion"; + String PROPERTY_HARDWARE_VERSION = "hardwareVersion"; /** the key for the firmware version property */ - final String PROPERTY_FIRMWARE_VERSION = "firmwareVersion"; + String PROPERTY_FIRMWARE_VERSION = "firmwareVersion"; /** the key for the MAC address property */ - final String PROPERTY_MAC_ADDRESS = "macAddress"; + String PROPERTY_MAC_ADDRESS = "macAddress"; /** * Returns the human readable label for this thing. diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingManager.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingManager.java index 28eeead5ff7..91400f74f3f 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingManager.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingManager.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/ThingProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingProvider.java index 1f2a67db13b..f8db02e49f5 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/ThingRegistry.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingRegistry.java index 59a183ba576..c7240578040 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingRegistry.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/ThingRegistryChangeListener.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingRegistryChangeListener.java index 5e863487dae..fde30b159a5 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingRegistryChangeListener.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingRegistryChangeListener.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/ThingStatus.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingStatus.java index 747c6b0bebd..18937cd97c9 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingStatus.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingStatus.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/ThingStatusDetail.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingStatusDetail.java index a6b0347b487..533ebac0965 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingStatusDetail.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingStatusDetail.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 @@ private UninitializedStatus() { public ThingStatusDetail HANDLER_CONFIGURATION_PENDING = ThingStatusDetail.HANDLER_CONFIGURATION_PENDING; public ThingStatusDetail HANDLER_INITIALIZING_ERROR = ThingStatusDetail.HANDLER_INITIALIZING_ERROR; public ThingStatusDetail BRIDGE_UNINITIALIZED = ThingStatusDetail.BRIDGE_UNINITIALIZED; - }; + } public static final class OnlineStatus { private OnlineStatus() { @@ -75,7 +75,7 @@ private OnlineStatus() { public ThingStatusDetail NONE = ThingStatusDetail.NONE; public ThingStatusDetail CONFIGURATION_PENDING = ThingStatusDetail.CONFIGURATION_PENDING; - }; + } public static final class OfflineStatus { private OfflineStatus() { @@ -88,5 +88,5 @@ private OfflineStatus() { public ThingStatusDetail FIRMWARE_UPDATING = ThingStatusDetail.FIRMWARE_UPDATING; public ThingStatusDetail DUTY_CYCLE = ThingStatusDetail.DUTY_CYCLE; public ThingStatusDetail GONE = ThingStatusDetail.GONE; - }; + } } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingStatusInfo.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingStatusInfo.java index 0ca6ea43f70..48411c8e2de 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingStatusInfo.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingStatusInfo.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/ThingTypeMigrationService.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingTypeMigrationService.java index 62361fb91ae..c8f9c9a8f61 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingTypeMigrationService.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingTypeMigrationService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/ThingTypeUID.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingTypeUID.java index e389f9f7ac6..584677dfb2b 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingTypeUID.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingTypeUID.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/ThingUID.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingUID.java index da50466ead8..db47b81a200 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingUID.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/ThingUID.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/UID.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/UID.java index fb1869afa00..77f9c2347c7 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/UID.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/UID.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/AbstractDynamicDescriptionProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/AbstractDynamicDescriptionProvider.java index 117db21c576..cc72da202ea 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/AbstractDynamicDescriptionProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/AbstractDynamicDescriptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/AbstractStorageBasedTypeProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/AbstractStorageBasedTypeProvider.java index b6f4740115c..3853a21dbb1 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/AbstractStorageBasedTypeProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/AbstractStorageBasedTypeProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -75,7 +75,7 @@ public abstract class AbstractStorageBasedTypeProvider * * @param storageService a persistent {@link StorageService} */ - public AbstractStorageBasedTypeProvider(StorageService storageService) { + protected AbstractStorageBasedTypeProvider(StorageService storageService) { String thingTypeStorageName = getClass().getName() + "-ThingType"; String channelTypeStorageName = getClass().getName() + "-ChannelType"; String channelGroupTypeStorageName = getClass().getName() + "-ChannelGroupType"; diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BaseBridgeHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BaseBridgeHandler.java index cd13c368949..e2d008ece20 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BaseBridgeHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BaseBridgeHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/BaseDynamicCommandDescriptionProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BaseDynamicCommandDescriptionProvider.java index 095e7df1096..259e827caf0 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BaseDynamicCommandDescriptionProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BaseDynamicCommandDescriptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/BaseDynamicStateDescriptionProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BaseDynamicStateDescriptionProvider.java index 4763ce71ae2..d8d3f74d6a3 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BaseDynamicStateDescriptionProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BaseDynamicStateDescriptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/BaseThingHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BaseThingHandler.java index e5fa558b3bd..cfe810c2413 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BaseThingHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BaseThingHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/BaseThingHandlerFactory.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BaseThingHandlerFactory.java index b991c7117c9..579993f2327 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BaseThingHandlerFactory.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BaseThingHandlerFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,9 +15,9 @@ import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import java.util.HashSet; -import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -34,8 +34,12 @@ import org.openhab.core.thing.type.ThingType; import org.openhab.core.thing.type.ThingTypeRegistry; import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceObjects; +import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceRegistration; import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.ServiceScope; import org.osgi.util.tracker.ServiceTracker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,10 +56,13 @@ * @author Thomas Höfer - added config status provider and firmware update handler service registration * @author Stefan Bußweiler - API changes due to bridge/thing life cycle refactoring, removed OSGi service registration * for thing handlers + * @author Connor Petty - added osgi service registration for thing handler services. */ @NonNullByDefault public abstract class BaseThingHandlerFactory implements ThingHandlerFactory { + private static final String THING_HANDLER_SERVICE_CANONICAL_NAME = ThingHandlerService.class.getCanonicalName(); + protected @NonNullByDefault({}) BundleContext bundleContext; private final Logger logger = LoggerFactory.getLogger(BaseThingHandlerFactory.class); @@ -63,7 +70,7 @@ public abstract class BaseThingHandlerFactory implements ThingHandlerFactory { private final Map> configStatusProviders = new ConcurrentHashMap<>(); private final Map> firmwareUpdateHandlers = new ConcurrentHashMap<>(); - private final Map>> thingHandlerServices = new ConcurrentHashMap<>(); + private final Map>> thingHandlerServices = new ConcurrentHashMap<>(); private @NonNullByDefault({}) ServiceTracker thingTypeRegistryServiceTracker; private @NonNullByDefault({}) ServiceTracker configDescriptionRegistryServiceTracker; @@ -143,67 +150,72 @@ public ThingHandler registerHandler(Thing thing) { private void registerServices(Thing thing, ThingHandler thingHandler) { ThingUID thingUID = thing.getUID(); - for (Class c : thingHandler.getServices()) { - try { - Object serviceInstance = c.getConstructor().newInstance(); - - ThingHandlerService ths = null; - if (serviceInstance instanceof ThingHandlerService service) { - ths = service; - ths.setThingHandler(thingHandler); - } else { - logger.warn( - "Should register service={} for thingUID={}, but it does not implement the interface ThingHandlerService.", - c.getCanonicalName(), thingUID); - continue; - } + for (Class c : thingHandler.getServices()) { + if (!ThingHandlerService.class.isAssignableFrom(c)) { + logger.warn( + "Should register service={} for thingUID={}, but it does not implement the interface ThingHandlerService.", + c.getCanonicalName(), thingUID); + continue; + } + registerThingHandlerService(thingUID, thingHandler, c); + } + } - Set> interfaces = getAllInterfaces(c); - List serviceNames = new LinkedList<>(); - interfaces.forEach(i -> { - String className = i.getCanonicalName(); - // we only add specific ThingHandlerServices, i.e. those that derive from the ThingHandlerService - // interface, NOT the ThingHandlerService itself. We do this to register them as specific OSGi - // services later, rather than as a generic ThingHandlerService. - if (className != null && !className.equals(ThingHandlerService.class.getCanonicalName())) { - serviceNames.add(className); - } - }); - if (!serviceNames.isEmpty()) { - String[] serviceNamesArray = serviceNames.toArray(new String[serviceNames.size()]); - ServiceRegistration serviceReg = bundleContext.registerService(serviceNamesArray, - serviceInstance, null); - if (serviceReg != null) { - Set> serviceRegs = thingHandlerServices.get(thingUID); - if (serviceRegs == null) { - Set> set = new HashSet<>(); - set.add(serviceReg); - thingHandlerServices.put(thingUID, set); - } else { - serviceRegs.add(serviceReg); - } - ths.activate(); - } - } + private void registerThingHandlerService(ThingUID thingUID, + ThingHandler thingHandler, Class c) { + RegisteredThingHandlerService registeredService; + + Component component = c.getAnnotation(Component.class); + if (component != null && component.enabled()) { + if (component.scope() != ServiceScope.PROTOTYPE) { + // then we cannot use it. + logger.warn("Could not register service for class={}. Service must have a prototype scope", + c.getCanonicalName()); + return; + } + if (component.service().length != 1 || component.service()[0] != c) { + logger.warn( + "Could not register service for class={}. ThingHandlerService with @Component must only label itself as a service.", + c.getCanonicalName()); + return; + } + } + + ServiceReference serviceRef = bundleContext.getServiceReference(c); + if (serviceRef != null) { + ServiceObjects serviceObjs = bundleContext.getServiceObjects(serviceRef); + registeredService = new RegisteredThingHandlerService<>(serviceObjs); + } else { + try { + T serviceInstance = c.getConstructor().newInstance(); + registeredService = new RegisteredThingHandlerService<>(serviceInstance); } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | InvocationTargetException e) { logger.warn("Could not register service for class={}", c.getCanonicalName(), e); + return; } } + + String[] serviceNames = getAllInterfaces(c).stream()// + .map(Class::getCanonicalName) + // we only add specific ThingHandlerServices, i.e. those that derive from the + // ThingHandlerService + // interface, NOT the ThingHandlerService itself. We do this to register them as specific OSGi + // services later, rather than as a generic ThingHandlerService. + .filter(className -> className != null && !className.equals(THING_HANDLER_SERVICE_CANONICAL_NAME)) + .toArray(String[]::new); + + registeredService.initializeService(thingHandler, serviceNames); + + Objects.requireNonNull(thingHandlerServices.computeIfAbsent(thingUID, uid -> new HashSet<>())) + .add(registeredService); } private void unregisterServices(Thing thing) { ThingUID thingUID = thing.getUID(); - Set> serviceRegs = thingHandlerServices.remove(thingUID); + Set> serviceRegs = thingHandlerServices.remove(thingUID); if (serviceRegs != null) { - serviceRegs.forEach(serviceReg -> { - ThingHandlerService ths = (ThingHandlerService) getBundleContext() - .getService(serviceReg.getReference()); - serviceReg.unregister(); - if (ths != null) { - ths.deactivate(); - } - }); + serviceRegs.forEach(RegisteredThingHandlerService::disposeService); } } @@ -213,7 +225,7 @@ private void unregisterServices(Thing thing) { * @param clazz The class * @return A {@link List} of interfaces */ - private Set> getAllInterfaces(Class clazz) { + private static Set> getAllInterfaces(Class clazz) { Set> interfaces = new HashSet<>(); for (Class superclazz = clazz; superclazz != null; superclazz = superclazz.getSuperclass()) { interfaces.addAll(Arrays.asList(superclazz.getInterfaces())); @@ -354,4 +366,47 @@ public void removeThing(ThingUID thingUID) { } return configDescriptionRegistryServiceTracker.getService(); } + + private class RegisteredThingHandlerService { + + private final T serviceInstance; + + private @Nullable ServiceObjects serviceObjects; + + private @Nullable ServiceRegistration serviceRegistration; + + public RegisteredThingHandlerService(T serviceInstance) { + this.serviceInstance = serviceInstance; + } + + public RegisteredThingHandlerService(ServiceObjects serviceObjs) { + this.serviceInstance = serviceObjs.getService(); + this.serviceObjects = serviceObjs; + } + + public void initializeService(ThingHandler handler, String[] serviceNames) { + serviceInstance.setThingHandler(handler); + if (serviceNames.length > 0) { + ServiceRegistration serviceReg = bundleContext.registerService(serviceNames, serviceInstance, null); + if (serviceReg != null) { + serviceRegistration = serviceReg; + } + } + serviceInstance.initialize(); + } + + public void disposeService() { + serviceInstance.dispose(); + + ServiceRegistration serviceReg = this.serviceRegistration; + if (serviceReg != null) { + serviceReg.unregister(); + } + + ServiceObjects serviceObjs = this.serviceObjects; + if (serviceObjs != null) { + serviceObjs.ungetService(serviceInstance); + } + } + } } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BridgeHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BridgeHandler.java index c3f912159b4..8ea39cc0462 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BridgeHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BridgeHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/ConfigStatusBridgeHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ConfigStatusBridgeHandler.java index 1433be1335e..157876b891f 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ConfigStatusBridgeHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ConfigStatusBridgeHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/ConfigStatusThingHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ConfigStatusThingHandler.java index 551a1805a46..254233e48ab 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ConfigStatusThingHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ConfigStatusThingHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/ThingActions.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingActions.java index d4ec53fd4cd..65fea044d43 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingActions.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingActions.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/ThingActionsScope.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingActionsScope.java index 5f2f742776c..15b4ec9df12 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingActionsScope.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingActionsScope.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/ThingConfigStatusSource.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingConfigStatusSource.java index 74bb74dc57d..5eb5764ea83 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingConfigStatusSource.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingConfigStatusSource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/ThingFactory.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingFactory.java index 640c43e561c..671d59c6939 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingFactory.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,6 +14,7 @@ import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.UUID; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -53,7 +54,7 @@ public class ThingFactory { */ public static ThingUID generateRandomThingUID(ThingTypeUID thingTypeUID) { String uuid = UUID.randomUUID().toString(); - String thingId = uuid.substring(uuid.length() - 12, uuid.length()); + String thingId = uuid.substring(uuid.length() - 12); return new ThingUID(thingTypeUID, thingId); } @@ -105,8 +106,8 @@ public static Thing createThing(ThingType thingType, ThingUID thingUID, Configur thingHandlerFactory.getClass(), thingTypeUID); } else { if (properties != null) { - for (String key : properties.keySet()) { - thing.setProperty(key, properties.get(key)); + for (Entry entry : properties.entrySet()) { + thing.setProperty(entry.getKey(), entry.getValue()); } } } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingHandler.java index 61f2444cce8..9e4e49dbf74 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/ThingHandlerCallback.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingHandlerCallback.java index 0450db7354c..fb04d6580ce 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingHandlerCallback.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingHandlerCallback.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/ThingHandlerFactory.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingHandlerFactory.java index 220194ace7b..391c2c9491a 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingHandlerFactory.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingHandlerFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/ThingHandlerService.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingHandlerService.java index 8b373a1737b..6e105dfbee0 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingHandlerService.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingHandlerService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -40,14 +40,44 @@ public interface ThingHandlerService { ThingHandler getThingHandler(); /** - * Method that will be called if this service will be activated + * This method is used by the framework during activation of the OSGi component. + * It is called BEFORE the thing handler is set. + * + * See {@link #initialize()}, {@link #deactivate()} */ default void activate() { } /** - * Method that will be called if this service will be deactivated + * This method is used by the framework during de-activation of the OSGi component. + * It is NOT guaranteed that the thing handler is still valid. + * + * See {@link #dispose()}, {@link #activate()} */ default void deactivate() { } + + /** + * This method is used by the framework during activation of the service. + * It is called AFTER the component is fully activated and thing handler has been set. + * + * Implementations should override this method to add additional initialization code. This method should call + * super.initialize() to ensure background discovery is properly handled. + * + * See {@link #activate()}, {@link #dispose()} + */ + default void initialize() { + } + + /** + * This method is used by the framework during de-activation of the service. + * It is called while the component is still activated. + * + * Code depending on an activated service should go here. This method should call super.dispose() to + * ensure background discovery is properly handled. + * + * See {@link #deactivate()}, {@link #initialize()} + */ + default void dispose() { + } } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingTypeProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingTypeProvider.java index bc54dac6524..86a225ff7b8 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingTypeProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/ThingTypeProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/builder/BridgeBuilder.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/builder/BridgeBuilder.java index d96dce95054..415fd3a70da 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/builder/BridgeBuilder.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/builder/BridgeBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/builder/ChannelBuilder.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/builder/ChannelBuilder.java index b7703a19ba6..58b096dff7c 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/builder/ChannelBuilder.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/builder/ChannelBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 static ChannelBuilder create(Channel channel) { ChannelBuilder channelBuilder = create(channel.getUID(), channel.getAcceptedItemType()) .withConfiguration(channel.getConfiguration()).withDefaultTags(channel.getDefaultTags()) .withKind(channel.getKind()).withProperties(channel.getProperties()) - .withType(channel.getChannelTypeUID()); + .withType(channel.getChannelTypeUID()).withAutoUpdatePolicy(channel.getAutoUpdatePolicy()); String label = channel.getLabel(); if (label != null) { channelBuilder.withLabel(label); diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/builder/ThingBuilder.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/builder/ThingBuilder.java index 72439c8e2c6..a05a9da7f5a 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/builder/ThingBuilder.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/builder/ThingBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/builder/ThingStatusInfoBuilder.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/builder/ThingStatusInfoBuilder.java index 499e1db9323..f3b9812755d 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/builder/ThingStatusInfoBuilder.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/builder/ThingStatusInfoBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/firmware/Firmware.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/Firmware.java index c3e6c756f5a..34fc82a88c5 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/Firmware.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/Firmware.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -65,7 +65,7 @@ public interface Firmware extends Comparable { /** The key for the requires a factory reset property. */ - static final String PROPERTY_REQUIRES_FACTORY_RESET = "requiresFactoryReset"; + String PROPERTY_REQUIRES_FACTORY_RESET = "requiresFactoryReset"; /** * Returns the thing type UID, that this firmware is associated with. diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/FirmwareBuilder.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/FirmwareBuilder.java index 674451f37bc..565a51a6cb2 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/FirmwareBuilder.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/FirmwareBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/firmware/FirmwareRestriction.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/FirmwareRestriction.java index 01f954b5260..ae2f4cd6599 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/FirmwareRestriction.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/FirmwareRestriction.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/firmware/FirmwareUpdateBackgroundTransferHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/FirmwareUpdateBackgroundTransferHandler.java index 961838fa0e3..c9f46d06b20 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/FirmwareUpdateBackgroundTransferHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/FirmwareUpdateBackgroundTransferHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/firmware/FirmwareUpdateHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/FirmwareUpdateHandler.java index 02c705addd5..80b188c0cc1 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/FirmwareUpdateHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/FirmwareUpdateHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,18 +12,20 @@ */ package org.openhab.core.thing.binding.firmware; +import java.util.Locale; + import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingStatus; import org.openhab.core.thing.ThingStatusDetail; +import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.firmware.FirmwareUpdateService; /** * The {@link FirmwareUpdateHandler} can be implemented and registered as an OSGi service in order to update the * firmware for the physical device of a {@link Thing}. The {@link FirmwareUpdateService} tracks each firmware * update handler and starts the firmware update process by the operation - * {@link FirmwareUpdateService#updateFirmware(org.openhab.core.thing.ThingUID, FirmwareUID, java.util.Locale)} - * . + * {@link FirmwareUpdateService#updateFirmware(ThingUID, String, Locale)}. * * @author Thomas Höfer - Initial contribution */ diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/ProgressCallback.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/ProgressCallback.java index 70a44312c7f..719978dd1ae 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/ProgressCallback.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/ProgressCallback.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 @@ * * For updates which are based on a percentage progress it is optional to define a sequence of {@link ProgressStep}s and * to use the {@link ProgressCallback#next()} method. In order to indicate that the percentage progress has changed, the - * method {@link ProgressCallback#update(progress)} has to be used. It allows to update the percentage progress to a + * method {@link ProgressCallback#update(int)} has to be used. It allows to update the percentage progress to a * value between 0 and 100. * * @author Thomas Höfer - Initial contribution diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/ProgressStep.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/ProgressStep.java index 6bcd881f617..f9fb14b738e 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/ProgressStep.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/firmware/ProgressStep.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelHandler.java index eda80471861..3887d2dfd19 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -45,7 +45,7 @@ public interface ChannelHandler { void send(Command command); @FunctionalInterface - public interface Factory { + interface Factory { ChannelHandler create(Consumer updateState, Consumer postCommand, @Nullable Consumer sendHttpValue, ChannelTransformation stateTransformations, ChannelTransformation commandTransformations, ChannelValueConverterConfig channelConfig); diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelHandlerContent.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelHandlerContent.java index ed5b4ad3e15..a4cbb720271 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelHandlerContent.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelHandlerContent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelMode.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelMode.java index 63353866747..90462fe5259 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelMode.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelMode.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelTransformation.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelTransformation.java index e4187cdae13..bad4fecb3ca 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelTransformation.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelTransformation.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelValueConverterConfig.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelValueConverterConfig.java index 72dd8a8a053..19fee482ca2 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelValueConverterConfig.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/ChannelValueConverterConfig.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/ColorChannelHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/ColorChannelHandler.java index c2dff0ef26f..5514c31d7b6 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/ColorChannelHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/ColorChannelHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -77,32 +77,29 @@ public String toString(Command command) { public Optional toState(String string) { State newState = UnDefType.UNDEF; if (string.equals(channelConfig.onValue)) { - if (state instanceof HSBType) { - newState = new HSBType(((HSBType) state).getHue(), ((HSBType) state).getSaturation(), - PercentType.HUNDRED); + if (state instanceof HSBType hsbState) { + newState = new HSBType(hsbState.getHue(), hsbState.getSaturation(), PercentType.HUNDRED); } else { newState = HSBType.WHITE; } } else if (string.equals(channelConfig.offValue)) { - if (state instanceof HSBType) { - newState = new HSBType(((HSBType) state).getHue(), ((HSBType) state).getSaturation(), PercentType.ZERO); + if (state instanceof HSBType hsbState) { + newState = new HSBType(hsbState.getHue(), hsbState.getSaturation(), PercentType.ZERO); } else { newState = HSBType.BLACK; } - } else if (string.equals(channelConfig.increaseValue) && state instanceof HSBType) { - BigDecimal newBrightness = ((HSBType) state).getBrightness().toBigDecimal().add(channelConfig.step); + } else if (string.equals(channelConfig.increaseValue) && state instanceof HSBType hsbState) { + BigDecimal newBrightness = hsbState.getBrightness().toBigDecimal().add(channelConfig.step); if (HUNDRED.compareTo(newBrightness) < 0) { newBrightness = HUNDRED; } - newState = new HSBType(((HSBType) state).getHue(), ((HSBType) state).getSaturation(), - new PercentType(newBrightness)); - } else if (string.equals(channelConfig.decreaseValue) && state instanceof HSBType) { - BigDecimal newBrightness = ((HSBType) state).getBrightness().toBigDecimal().subtract(channelConfig.step); + newState = new HSBType(hsbState.getHue(), hsbState.getSaturation(), new PercentType(newBrightness)); + } else if (string.equals(channelConfig.decreaseValue) && state instanceof HSBType hsbState) { + BigDecimal newBrightness = hsbState.getBrightness().toBigDecimal().subtract(channelConfig.step); if (BigDecimal.ZERO.compareTo(newBrightness) > 0) { newBrightness = BigDecimal.ZERO; } - newState = new HSBType(((HSBType) state).getHue(), ((HSBType) state).getSaturation(), - new PercentType(newBrightness)); + newState = new HSBType(hsbState.getHue(), hsbState.getSaturation(), new PercentType(newBrightness)); } else { Matcher matcher = TRIPLE_MATCHER.matcher(string); if (matcher.matches()) { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/DimmerChannelHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/DimmerChannelHandler.java index f9980de7831..01ebf5517d1 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/DimmerChannelHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/DimmerChannelHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -56,8 +56,8 @@ public String toString(Command command) { return string; } - if (command instanceof PercentType) { - return ((PercentType) command).toString(); + if (command instanceof PercentType percentCommand) { + return percentCommand.toString(); } throw new IllegalArgumentException("Command type '" + command.toString() + "' not supported"); @@ -71,14 +71,14 @@ public Optional toState(String string) { newState = PercentType.HUNDRED; } else if (string.equals(channelConfig.offValue)) { newState = PercentType.ZERO; - } else if (string.equals(channelConfig.increaseValue) && state instanceof PercentType) { - BigDecimal newBrightness = ((PercentType) state).toBigDecimal().add(channelConfig.step); + } else if (string.equals(channelConfig.increaseValue) && state instanceof PercentType percentState) { + BigDecimal newBrightness = percentState.toBigDecimal().add(channelConfig.step); if (HUNDRED.compareTo(newBrightness) < 0) { newBrightness = HUNDRED; } newState = new PercentType(newBrightness); - } else if (string.equals(channelConfig.decreaseValue) && state instanceof PercentType) { - BigDecimal newBrightness = ((PercentType) state).toBigDecimal().subtract(channelConfig.step); + } else if (string.equals(channelConfig.decreaseValue) && state instanceof PercentType percentState) { + BigDecimal newBrightness = percentState.toBigDecimal().subtract(channelConfig.step); if (BigDecimal.ZERO.compareTo(newBrightness) > 0) { newBrightness = BigDecimal.ZERO; } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/FixedValueMappingChannelHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/FixedValueMappingChannelHandler.java index 47ea726d3b6..7878695f38a 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/FixedValueMappingChannelHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/FixedValueMappingChannelHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/GenericChannelHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/GenericChannelHandler.java index aa25055270c..72554ddfe53 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/GenericChannelHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/GenericChannelHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/ImageChannelHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/ImageChannelHandler.java index ff23ea3289b..44fc089976c 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/ImageChannelHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/ImageChannelHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/NumberChannelHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/NumberChannelHandler.java index 91a48514d4c..e56bd3262d0 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/NumberChannelHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/NumberChannelHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/PlayerChannelHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/PlayerChannelHandler.java index 0afe6f41c18..ac19065fe29 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/PlayerChannelHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/PlayerChannelHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/RollershutterChannelHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/RollershutterChannelHandler.java index cf0ef1df0a6..9068fdf1bf9 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/RollershutterChannelHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/generic/converter/RollershutterChannelHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +51,7 @@ public String toString(Command command) { return string; } - if (command instanceof PercentType) { + if (command instanceof PercentType percentCommand) { final String downValue = channelConfig.downValue; final String upValue = channelConfig.upValue; if (command.equals(PercentType.HUNDRED) && downValue != null) { @@ -59,7 +59,7 @@ public String toString(Command command) { } else if (command.equals(PercentType.ZERO) && upValue != null) { return upValue; } else { - return ((PercentType) command).toString(); + return percentCommand.toString(); } } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/AbstractThingDTO.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/AbstractThingDTO.java index d67c670a4a8..967ade4b4e8 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/AbstractThingDTO.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/AbstractThingDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 abstract class AbstractThingDTO { public String thingTypeUID; public String location; - public AbstractThingDTO() { + protected AbstractThingDTO() { } protected AbstractThingDTO(String thingTypeUID, String uid, String label, String bridgeUID, diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ChannelDTO.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ChannelDTO.java index 74d06418869..633f80fe22a 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ChannelDTO.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ChannelDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/dto/ChannelDTOMapper.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ChannelDTOMapper.java index 6f149ea131a..e92874f792f 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ChannelDTOMapper.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ChannelDTOMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/dto/ChannelDefinitionDTO.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ChannelDefinitionDTO.java index 65165f63238..8dfd0985642 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ChannelDefinitionDTO.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ChannelDefinitionDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/dto/ChannelGroupDefinitionDTO.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ChannelGroupDefinitionDTO.java index 711794bd9e4..9bbab426267 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ChannelGroupDefinitionDTO.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ChannelGroupDefinitionDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/dto/ChannelTypeDTO.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ChannelTypeDTO.java index 2c4c8ae8d44..2b1de820200 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ChannelTypeDTO.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ChannelTypeDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/dto/StrippedThingTypeDTO.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/StrippedThingTypeDTO.java index ed7d2715c31..c9be33b3920 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/StrippedThingTypeDTO.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/StrippedThingTypeDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/dto/StrippedThingTypeDTOMapper.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/StrippedThingTypeDTOMapper.java index 00ef7bf102e..5912f23e44e 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/StrippedThingTypeDTOMapper.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/StrippedThingTypeDTOMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/dto/ThingDTO.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ThingDTO.java index 36bf58a4cb6..324c633e294 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ThingDTO.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ThingDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/dto/ThingDTOMapper.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ThingDTOMapper.java index 53e0272dbe2..d6badf6e82c 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ThingDTOMapper.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ThingDTOMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/dto/ThingTypeDTO.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ThingTypeDTO.java index 5f9f6e13876..427892ccaa7 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ThingTypeDTO.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/dto/ThingTypeDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/events/AbstractThingRegistryEvent.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/AbstractThingRegistryEvent.java index 189c4b887b7..63b3f5914bf 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/AbstractThingRegistryEvent.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/AbstractThingRegistryEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/events/ChannelDescriptionChangedEvent.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ChannelDescriptionChangedEvent.java index e4aa9ab7ec2..8367ad6369b 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ChannelDescriptionChangedEvent.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ChannelDescriptionChangedEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -37,7 +37,7 @@ public enum CommonChannelDescriptionField { COMMAND_OPTIONS, PATTERN, STATE_OPTIONS - }; + } /** * The channel description changed event type. diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ChannelTriggeredEvent.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ChannelTriggeredEvent.java index 406904d05ff..d5a5d9e418a 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ChannelTriggeredEvent.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ChannelTriggeredEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/events/ThingAddedEvent.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingAddedEvent.java index 29cc4f4cf02..e1b3f27135c 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingAddedEvent.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingAddedEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/events/ThingEventFactory.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingEventFactory.java index 6e1c483fa89..6e8caed3d4b 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingEventFactory.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingEventFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -114,7 +114,7 @@ public ChannelDescriptionChangedEventPayloadBean(CommonChannelDescriptionField f } } - public static interface CommonChannelDescriptionFieldPayloadBean { + public interface CommonChannelDescriptionFieldPayloadBean { } public static class ChannelDescriptionPatternPayloadBean implements CommonChannelDescriptionFieldPayloadBean { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingRemovedEvent.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingRemovedEvent.java index d1bfa5f7863..8534464a086 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingRemovedEvent.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingRemovedEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/events/ThingStatusInfoChangedEvent.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingStatusInfoChangedEvent.java index 072585a550d..a0a082a7569 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingStatusInfoChangedEvent.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingStatusInfoChangedEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/events/ThingStatusInfoEvent.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingStatusInfoEvent.java index 8e777737785..80e8e202b70 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingStatusInfoEvent.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingStatusInfoEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/events/ThingUpdatedEvent.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingUpdatedEvent.java index 7f00eebe943..126f9795cca 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingUpdatedEvent.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/events/ThingUpdatedEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareEventFactory.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareEventFactory.java index 9073a9c0919..a81406d81e7 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareEventFactory.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareEventFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareProvider.java index e1282cf6f0b..f6c43495776 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareRegistry.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareRegistry.java index 4eea29f7bda..3544a9caea4 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareRegistry.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareStatus.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareStatus.java index b7bd713739b..1f1c2486094 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareStatus.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareStatus.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareStatusInfo.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareStatusInfo.java index 2d1cf20c501..624fc84bbd0 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareStatusInfo.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareStatusInfo.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareStatusInfoEvent.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareStatusInfoEvent.java index af9633def16..e648bd88b9a 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareStatusInfoEvent.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareStatusInfoEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateProgressInfo.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateProgressInfo.java index c0c594ccae7..62ae858f9d9 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateProgressInfo.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateProgressInfo.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateProgressInfoEvent.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateProgressInfoEvent.java index fc2896fa47c..9ccfa7302da 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateProgressInfoEvent.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateProgressInfoEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateResult.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateResult.java index 58c22154115..52f0f0a281e 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateResult.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateResult.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateResultInfo.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateResultInfo.java index bc2a58bb859..d0454b0b146 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateResultInfo.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateResultInfo.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateResultInfoEvent.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateResultInfoEvent.java index 7fe3fb32551..3a90b0fcbef 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateResultInfoEvent.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateResultInfoEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateService.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateService.java index f5d3e165a45..891f4fb9f60 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateService.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/FirmwareUpdateService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/firmware/dto/FirmwareDTO.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/dto/FirmwareDTO.java index b8f73513446..7ba4df7ba4d 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/dto/FirmwareDTO.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/dto/FirmwareDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/firmware/dto/FirmwareStatusDTO.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/dto/FirmwareStatusDTO.java index c12ea5e6328..36419954c50 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/dto/FirmwareStatusDTO.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/firmware/dto/FirmwareStatusDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/i18n/ChannelGroupTypeI18nLocalizationService.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/i18n/ChannelGroupTypeI18nLocalizationService.java index 9c9a4459476..9fbdb901b1a 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/i18n/ChannelGroupTypeI18nLocalizationService.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/i18n/ChannelGroupTypeI18nLocalizationService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/i18n/ChannelTypeI18nLocalizationService.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/i18n/ChannelTypeI18nLocalizationService.java index 5dd98c3ba45..0f74c172433 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/i18n/ChannelTypeI18nLocalizationService.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/i18n/ChannelTypeI18nLocalizationService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/i18n/ThingStatusInfoI18nLocalizationService.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/i18n/ThingStatusInfoI18nLocalizationService.java index 2b08a59221c..5b56a00f321 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/i18n/ThingStatusInfoI18nLocalizationService.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/i18n/ThingStatusInfoI18nLocalizationService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 String getTranslationForClass(String i18nConstant, Locale locale, Class< /** * Utility class to parse the thing status description into the text reference and optional arguments. */ - private final class ParsedDescription { + private static final class ParsedDescription { private static final int LIMIT = 2; @@ -172,7 +172,7 @@ private ParsedDescription(String description) { this.args = null; } else { this.args = Arrays.stream(parts[1].replaceAll("\\[|\\]|\"", "").split(",")) - .filter(s -> s != null && !s.trim().isEmpty()).map(s -> s.trim()).toArray(String[]::new); + .filter(s -> s != null && !s.trim().isEmpty()).map(String::trim).toArray(String[]::new); } } } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/i18n/ThingTypeI18nLocalizationService.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/i18n/ThingTypeI18nLocalizationService.java index 0810bd21320..eb622b992f9 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/i18n/ThingTypeI18nLocalizationService.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/i18n/ThingTypeI18nLocalizationService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/AutoUpdateConfigDescriptionProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/AutoUpdateConfigDescriptionProvider.java index f007fe733a3..4d49b8e15b7 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/AutoUpdateConfigDescriptionProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/AutoUpdateConfigDescriptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/AutoUpdateManager.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/AutoUpdateManager.java index e7abeef6198..1af2d79ef05 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/AutoUpdateManager.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/AutoUpdateManager.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -75,7 +75,7 @@ public class AutoUpdateManager { private boolean enabled = true; private boolean sendOptimisticUpdates = false; - private static enum Recommendation { + private enum Recommendation { /* * An automatic state update must be sent because no channels are linked to the item. */ @@ -204,7 +204,7 @@ private Recommendation shouldAutoUpdate(Item item) { for (ChannelUID channelUID : linkedChannelUIDs) { Thing thing = thingRegistry.get(channelUID.getThingUID()); if (thing == null // - || thing.getChannel(channelUID.getId()) == null // + || thing.getChannel(channelUID) == null // || thing.getHandler() == null // || !ThingStatus.ONLINE.equals(thing.getStatus()) // ) { @@ -223,7 +223,7 @@ private Recommendation shouldAutoUpdate(Item item) { continue; } AutoUpdatePolicy policy = AutoUpdatePolicy.DEFAULT; - Channel channel = thing.getChannel(channelUID.getId()); + Channel channel = thing.getChannel(channelUID); if (channel != null) { AutoUpdatePolicy channelpolicy = channel.getAutoUpdatePolicy(); if (channelpolicy != null) { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/BridgeImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/BridgeImpl.java index c24b3e8433e..ad13e86e506 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/BridgeImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/BridgeImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -30,7 +30,7 @@ /** * * @author Denis Nobel - Initial contribution - * @author Christoph Weitkamp - Added method `getThing(ThingUID)` + * @author Christoph Weitkamp - Added method {@code getThing(ThingUID)} */ @NonNullByDefault public class BridgeImpl extends ThingImpl implements Bridge { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ChannelCommandDescriptionProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ChannelCommandDescriptionProvider.java index 2392b92113e..e7c76c9f15c 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ChannelCommandDescriptionProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ChannelCommandDescriptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 ChannelCommandDescriptionProvider(final @Reference ItemChannelLinkRegistr if (dynamicCommandDescription == originalCommandDescription) { logger.error( "Dynamic command description matches original command description. DynamicCommandDescriptionProvider implementations must never return the original command description. {} has to be fixed.", - dynamicCommandDescription.getClass()); + dynamicCommandDescriptionProvider.getClass()); } else { return dynamicCommandDescription; } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ChannelLinkNotifier.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ChannelLinkNotifier.java index 0a14dda7682..fc5e86f56c8 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ChannelLinkNotifier.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ChannelLinkNotifier.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/ChannelStateDescriptionProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ChannelStateDescriptionProvider.java index 4abdafed7e0..d2a7abe51e3 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ChannelStateDescriptionProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ChannelStateDescriptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/CommunicationManager.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/CommunicationManager.java index 10fb9d414a0..f7d204addbf 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/CommunicationManager.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/CommunicationManager.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -228,13 +228,13 @@ private ProfileCallback createCallback(ItemChannelLink link) { private @Nullable ProfileTypeUID determineProfileTypeUID(ItemChannelLink link, Item item, @Nullable Thing thing) { ProfileTypeUID profileTypeUID = getConfiguredProfileTypeUID(link); - Channel channel = null; + Channel channel; if (profileTypeUID == null) { if (thing == null) { return null; } - channel = thing.getChannel(link.getLinkedUID().getId()); + channel = thing.getChannel(link.getLinkedUID()); if (channel == null) { return null; } @@ -399,7 +399,7 @@ private void handleEvent(String itemName, T type, @Nullable Str ThingUID thingUID = channelUID.getThingUID(); Thing thing = thingRegistry.get(thingUID); if (thing != null) { - Channel channel = thing.getChannel(channelUID.getId()); + Channel channel = thing.getChannel(channelUID); if (channel != null) { if (thing.getHandler() != null) { // fix QuantityType/DecimalType, leave others as-is diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ProfileContextImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ProfileContextImpl.java index 10766eb64cf..d4ff2667835 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ProfileContextImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ProfileContextImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/ThingConfigDescriptionAliasProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingConfigDescriptionAliasProvider.java index 3b140c0bec7..7fd7e064975 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingConfigDescriptionAliasProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingConfigDescriptionAliasProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -106,7 +106,7 @@ public ThingConfigDescriptionAliasProvider(final @Reference ThingRegistry thingR return null; } - Channel channel = thing.getChannel(channelUID.getId()); + Channel channel = thing.getChannel(channelUID); if (channel == null) { return null; } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingFactoryHelper.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingFactoryHelper.java index 3322f845f0b..9cdb1ba21e7 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingFactoryHelper.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingFactoryHelper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,6 +26,7 @@ import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.ThingFactory; import org.openhab.core.thing.binding.builder.ChannelBuilder; +import org.openhab.core.thing.type.AutoUpdatePolicy; import org.openhab.core.thing.type.ChannelDefinition; import org.openhab.core.thing.type.ChannelGroupDefinition; import org.openhab.core.thing.type.ChannelGroupType; @@ -184,12 +185,17 @@ public static ChannelBuilder createChannelBuilder(ChannelUID channelUID, Channel label = channelType.getLabel(); } + AutoUpdatePolicy autoUpdatePolicy = channelDefinition.getAutoUpdatePolicy(); + if (autoUpdatePolicy == null) { + autoUpdatePolicy = channelType.getAutoUpdatePolicy(); + } + final ChannelBuilder channelBuilder = ChannelBuilder.create(channelUID, channelType.getItemType()) // .withType(channelType.getUID()) // .withDefaultTags(channelType.getTags()) // .withKind(channelType.getKind()) // .withLabel(label) // - .withAutoUpdatePolicy(channelType.getAutoUpdatePolicy()); + .withAutoUpdatePolicy(autoUpdatePolicy); String description = channelDefinition.getDescription(); if (description == null) { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingHandlerCallbackImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingHandlerCallbackImpl.java index 184b652dc01..d971cff165f 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingHandlerCallbackImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingHandlerCallbackImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -226,7 +226,7 @@ public ChannelBuilder createChannelBuilder(ChannelUID channelUID, ChannelTypeUID @Override public ChannelBuilder editChannel(Thing thing, ChannelUID channelUID) { - Channel channel = thing.getChannel(channelUID.getId()); + Channel channel = thing.getChannel(channelUID); if (channel == null) { throw new IllegalArgumentException( String.format("Channel '%s' does not exist for thing '%s'", channelUID, thing.getUID())); diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingImpl.java index 20e7d9487b6..5e78aac9837 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +43,7 @@ * ThingType Description * @author Thomas Höfer - Added thing and thing type properties * @author Simon Kaufmann - Added label - * @author Christoph Weitkamp - Added method `getChannel(ChannelUID)` + * @author Christoph Weitkamp - Added method {@code getChannel(ChannelUID)} */ @NonNullByDefault public class ThingImpl implements Thing { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingManagerImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingManagerImpl.java index e7482f7ec08..d36568af45f 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingManagerImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingManagerImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -1090,7 +1090,7 @@ private boolean checkAndPerformUpdate(Thing thing, ThingHandlerFactory factory) } // create a thing builder and apply the update instructions - ThingBuilder thingBuilder = thing instanceof Bridge ? BridgeBuilder.create((Bridge) thing) + ThingBuilder thingBuilder = thing instanceof Bridge bridge ? BridgeBuilder.create(bridge) : ThingBuilder.create(thing); instructions.forEach(instruction -> instruction.perform(thing, thingBuilder)); int newThingTypeVersion = instructions.get(instructions.size() - 1).getThingTypeVersion(); diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingRegistryImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingRegistryImpl.java index 860fd3999a7..cd7d1086dd8 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingRegistryImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingRegistryImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -80,7 +80,7 @@ public void addThingTracker(ThingTracker thingTracker) { ThingUID thingUID = channelUID.getThingUID(); Thing thing = get(thingUID); if (thing != null) { - return thing.getChannel(channelUID.getId()); + return thing.getChannel(channelUID); } return null; } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingStorageEntity.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingStorageEntity.java index 7a250d111bf..a95f8f24127 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingStorageEntity.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingStorageEntity.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/ThingTracker.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingTracker.java index bc4815e88c9..466f2e8b54c 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingTracker.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/ThingTracker.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/binding/generic/converter/AbstractTransformingChannelHandler.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/binding/generic/converter/AbstractTransformingChannelHandler.java index 0850dccb31d..4b48e46c917 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/binding/generic/converter/AbstractTransformingChannelHandler.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/binding/generic/converter/AbstractTransformingChannelHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -41,7 +41,7 @@ public abstract class AbstractTransformingChannelHandler implements ChannelHandl protected final ChannelValueConverterConfig channelConfig; - public AbstractTransformingChannelHandler(Consumer updateState, Consumer postCommand, + protected AbstractTransformingChannelHandler(Consumer updateState, Consumer postCommand, @Nullable Consumer sendValue, ChannelTransformation stateTransformations, ChannelTransformation commandTransformations, ChannelValueConverterConfig channelConfig) { this.updateState = updateState; diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/console/FirmwareUpdateConsoleCommandExtension.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/console/FirmwareUpdateConsoleCommandExtension.java index 36f02b5dca4..a5bb0f74074 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/console/FirmwareUpdateConsoleCommandExtension.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/console/FirmwareUpdateConsoleCommandExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/console/LinkConsoleCommandExtension.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/console/LinkConsoleCommandExtension.java index 0caf2927ab0..b83b392aa0c 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/console/LinkConsoleCommandExtension.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/console/LinkConsoleCommandExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/console/ThingConsoleCommandExtension.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/console/ThingConsoleCommandExtension.java index 789743c578a..9465c6fd59b 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/console/ThingConsoleCommandExtension.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/console/ThingConsoleCommandExtension.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareImpl.java index 27d7a939bb3..fc7dc1488b0 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -189,7 +189,7 @@ public FirmwareRestriction getFirmwareRestriction() { digestString.append(String.format("%02x", b)); } - if (!md5Hash.equals(digestString.toString())) { + if (!md5Hash.contentEquals(digestString)) { bytes = null; throw new IllegalStateException( String.format("Invalid MD5 checksum. Expected %s, but was %s.", md5Hash, digestString)); diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareRegistryImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareRegistryImpl.java index d7d5bbb1211..66aad7a92ae 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareRegistryImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareRegistryImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareUpdateServiceImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareUpdateServiceImpl.java index a52ee0b030c..2ae362a72f8 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareUpdateServiceImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/FirmwareUpdateServiceImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/firmware/ParameterChecks.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/ParameterChecks.java index 582b69bfaf9..9d16f234d51 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/ParameterChecks.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/ParameterChecks.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/firmware/ProgressCallbackImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/ProgressCallbackImpl.java index 7b0596fb50e..b986cd5e677 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/ProgressCallbackImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/firmware/ProgressCallbackImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -64,7 +64,7 @@ private enum InternalState { PENDING, RUNNING, INITIALIZED - }; + } private InternalState state; @@ -183,7 +183,7 @@ private void updateProgress(int progress) { void failedInternal(String errorMessageKey) { this.state = InternalState.FINISHED; - String errorMessage = getMessage(ProgressCallbackImpl.class, errorMessageKey, new Object[] {}); + String errorMessage = getMessage(ProgressCallbackImpl.class, errorMessageKey); postResultInfoEvent(FirmwareUpdateResult.ERROR, errorMessage); } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/i18n/ChannelGroupI18nUtil.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/i18n/ChannelGroupI18nUtil.java index c51b34e7be4..7afc1327e4c 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/i18n/ChannelGroupI18nUtil.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/i18n/ChannelGroupI18nUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -30,7 +30,7 @@ * A utility service which localizes {@link ChannelGroupDefinition}. * Falls back to a localized {@link ChannelGroupType} for label and description when not given otherwise. * - * @see {@link ThingTypeI18nLocalizationService} + * @see org.openhab.core.thing.i18n.ThingTypeI18nLocalizationService ThingTypeI18nLocalizationService * * @author Christoph Weitkamp - Initial contribution */ diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/i18n/ChannelI18nUtil.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/i18n/ChannelI18nUtil.java index 210866edddc..2dca5d1e489 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/i18n/ChannelI18nUtil.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/i18n/ChannelI18nUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,8 +31,8 @@ * A utility service which localises {@link ChannelDefinition}. * Falls back to a localised {@link ChannelType} for label and description when not given otherwise. * - * @see {@link ThingTypeI18nLocalizationService} - * @see {@link ChannelGroupTypeI18nLocalizationService} + * @see org.openhab.core.thing.i18n.ThingTypeI18nLocalizationService ThingTypeI18nLocalizationService + * @see org.openhab.core.thing.i18n.ChannelGroupTypeI18nLocalizationService ChannelGroupTypeI18nLocalizationService * * @author Henning Treu - Initial contribution */ diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/i18n/ThingTypeI18nUtil.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/i18n/ThingTypeI18nUtil.java index 3c112e32c9f..189e1210157 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/i18n/ThingTypeI18nUtil.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/i18n/ThingTypeI18nUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/link/ItemChannelLinkConfigDescriptionProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/link/ItemChannelLinkConfigDescriptionProvider.java index 00694f6c6f9..f55aa438ab1 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/link/ItemChannelLinkConfigDescriptionProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/link/ItemChannelLinkConfigDescriptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -90,7 +90,7 @@ public Collection getConfigDescriptions(@Nullable Locale loca if (thing == null) { return null; } - Channel channel = thing.getChannel(link.getLinkedUID().getId()); + Channel channel = thing.getChannel(link.getLinkedUID()); if (channel == null) { return null; } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/ProfileCallbackImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/ProfileCallbackImpl.java index 6f30e255c72..6f410fb99d6 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/ProfileCallbackImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/ProfileCallbackImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/ProfileTypeRegistryImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/ProfileTypeRegistryImpl.java index 6c9862c7590..3c17d992621 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/ProfileTypeRegistryImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/ProfileTypeRegistryImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawButtonOnOffSwitchProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawButtonOnOffSwitchProfile.java index 314a255a233..69bdfe7ec89 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawButtonOnOffSwitchProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawButtonOnOffSwitchProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerDimmerProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerDimmerProfile.java index 7b295fbdd38..eb15ca494d4 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerDimmerProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerDimmerProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerNextPreviousProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerNextPreviousProfile.java index a53a5bcdefc..7028891c77e 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerNextPreviousProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerNextPreviousProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerOnOffProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerOnOffProfile.java index fb5fb4fc95b..2a87bf9d426 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerOnOffProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerOnOffProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerPlayPauseProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerPlayPauseProfile.java index e17f857893d..58381855e10 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerPlayPauseProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerPlayPauseProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerRewindFastforwardProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerRewindFastforwardProfile.java index c74ce870304..abbe6e7f1c9 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerRewindFastforwardProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerRewindFastforwardProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerStopMoveProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerStopMoveProfile.java index d426b0c2338..3559ebcd7b1 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerStopMoveProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerStopMoveProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerUpDownProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerUpDownProfile.java index 283a9651876..b2f2ef0b5f7 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerUpDownProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/RawRockerUpDownProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/StateProfileTypeImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/StateProfileTypeImpl.java index 0b47e246e59..af7b4433b95 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/StateProfileTypeImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/StateProfileTypeImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemDefaultProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemDefaultProfile.java index d54f02bc3ec..abdabefbe5a 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemDefaultProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemDefaultProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemFollowProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemFollowProfile.java index ad7506dabd1..ee9ed8d916a 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemFollowProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemFollowProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemHysteresisStateProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemHysteresisStateProfile.java index 1213fad1c44..9f79149fdca 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemHysteresisStateProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemHysteresisStateProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,9 +76,9 @@ public SystemHysteresisStateProfile(ProfileCallback callback, ProfileContext con this.upper = convertedUpperParam; final Object paramValue = context.getConfiguration().get(INVERTED_PARAM); - final boolean inverted = paramValue == null ? false : Boolean.valueOf(paramValue.toString()); - this.low = inverted ? OnOffType.ON : OnOffType.OFF; - this.high = inverted ? OnOffType.OFF : OnOffType.ON; + final boolean inverted = paramValue != null && Boolean.parseBoolean(paramValue.toString()); + this.low = OnOffType.from(inverted); + this.high = OnOffType.from(!inverted); } private @Nullable QuantityType getParam(ProfileContext context, String param) { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemOffsetProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemOffsetProfile.java index a2bbd509f6c..6bbcea5a810 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemOffsetProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemOffsetProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemProfileFactory.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemProfileFactory.java index c5ffdc4b69f..864184dbc7b 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemProfileFactory.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemProfileFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -106,29 +106,29 @@ public SystemProfileFactory(final @Reference ChannelTypeRegistry channelTypeRegi } else if (RANGE.equals(profileTypeUID)) { return new SystemRangeStateProfile(callback, context); } else if (BUTTON_TOGGLE_SWITCH.equals(profileTypeUID)) { - return new ToggleProfile(callback, context, BUTTON_TOGGLE_SWITCH, + return new ToggleProfile<>(callback, context, BUTTON_TOGGLE_SWITCH, DefaultSystemChannelTypeProvider.SYSTEM_BUTTON, OnOffType.ON, OnOffType.OFF, CommonTriggerEvents.SHORT_PRESSED); } else if (BUTTON_TOGGLE_PLAYER.equals(profileTypeUID)) { - return new ToggleProfile(callback, context, BUTTON_TOGGLE_PLAYER, + return new ToggleProfile<>(callback, context, BUTTON_TOGGLE_PLAYER, DefaultSystemChannelTypeProvider.SYSTEM_BUTTON, PlayPauseType.PLAY, PlayPauseType.PAUSE, CommonTriggerEvents.SHORT_PRESSED); } else if (BUTTON_TOGGLE_ROLLERSHUTTER.equals(profileTypeUID)) { - return new ToggleProfile(callback, context, BUTTON_TOGGLE_ROLLERSHUTTER, + return new ToggleProfile<>(callback, context, BUTTON_TOGGLE_ROLLERSHUTTER, DefaultSystemChannelTypeProvider.SYSTEM_BUTTON, UpDownType.UP, UpDownType.DOWN, CommonTriggerEvents.SHORT_PRESSED); } else if (RAWBUTTON_ON_OFF_SWITCH.equals(profileTypeUID)) { return new RawButtonOnOffSwitchProfile(callback); } else if (RAWBUTTON_TOGGLE_SWITCH.equals(profileTypeUID)) { - return new ToggleProfile(callback, context, RAWBUTTON_TOGGLE_SWITCH, + return new ToggleProfile<>(callback, context, RAWBUTTON_TOGGLE_SWITCH, DefaultSystemChannelTypeProvider.SYSTEM_RAWBUTTON, OnOffType.ON, OnOffType.OFF, CommonTriggerEvents.PRESSED); } else if (RAWBUTTON_TOGGLE_PLAYER.equals(profileTypeUID)) { - return new ToggleProfile(callback, context, RAWBUTTON_TOGGLE_PLAYER, + return new ToggleProfile<>(callback, context, RAWBUTTON_TOGGLE_PLAYER, DefaultSystemChannelTypeProvider.SYSTEM_RAWBUTTON, PlayPauseType.PLAY, PlayPauseType.PAUSE, CommonTriggerEvents.PRESSED); } else if (RAWBUTTON_TOGGLE_ROLLERSHUTTER.equals(profileTypeUID)) { - return new ToggleProfile(callback, context, RAWBUTTON_TOGGLE_ROLLERSHUTTER, + return new ToggleProfile<>(callback, context, RAWBUTTON_TOGGLE_ROLLERSHUTTER, DefaultSystemChannelTypeProvider.SYSTEM_RAWBUTTON, UpDownType.UP, UpDownType.DOWN, CommonTriggerEvents.PRESSED); } else if (RAWROCKER_DIMMER.equals(profileTypeUID)) { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemRangeStateProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemRangeStateProfile.java index 5de09b33d59..4d624105eb6 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemRangeStateProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/SystemRangeStateProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -83,9 +83,9 @@ public SystemRangeStateProfile(ProfileCallback callback, ProfileContext context) this.upper = convertedUpperParam; final Object paramValue = context.getConfiguration().get(INVERTED_PARAM); - final boolean inverted = paramValue == null ? false : Boolean.valueOf(paramValue.toString()); - this.inRange = inverted ? OnOffType.OFF : OnOffType.ON; - this.notInRange = inverted ? OnOffType.ON : OnOffType.OFF; + final boolean inverted = paramValue != null && Boolean.parseBoolean(paramValue.toString()); + this.inRange = OnOffType.from(!inverted); + this.notInRange = OnOffType.from(inverted); } private @Nullable QuantityType getParam(ProfileContext context, String param) { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TimestampChangeProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TimestampChangeProfile.java index 3ab02374ef6..43ef5c89142 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TimestampChangeProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TimestampChangeProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/TimestampOffsetProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TimestampOffsetProfile.java index 58a808d2347..2534fc6c885 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TimestampOffsetProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TimestampOffsetProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +61,7 @@ public TimestampOffsetProfile(ProfileCallback callback, ProfileContext context) if (offsetParam instanceof Number bd) { offset = Duration.ofSeconds(bd.longValue()); } else if (offsetParam instanceof String s) { - offset = Duration.ofSeconds(Long.valueOf(s)); + offset = Duration.ofSeconds(Long.parseLong(s)); } else { logger.error( "Parameter '{}' is not of type String or Number. Please make sure it is one of both, e.g. 3 or \"-1\".", @@ -118,7 +118,7 @@ private Type applyOffsetAndTimezone(Type type, boolean towardsItem) { } Duration finalOffset = towardsItem ? offset : offset.negated(); - Type result = UnDefType.UNDEF; + Type result; if (type instanceof DateTimeType timeType) { ZonedDateTime zdt = timeType.getZonedDateTime(); diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TimestampTriggerProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TimestampTriggerProfile.java index f88a2dabc73..34340ba1010 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TimestampTriggerProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TimestampTriggerProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/TimestampUpdateProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TimestampUpdateProfile.java index 10a1999f089..3f0a2090956 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TimestampUpdateProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TimestampUpdateProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/ToggleProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/ToggleProfile.java index 7350fe860c6..967cb1fdb58 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/ToggleProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/ToggleProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/TriggerEventStringProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TriggerEventStringProfile.java index ee4a0cf81dd..d025515b5f6 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TriggerEventStringProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TriggerEventStringProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/TriggerProfileTypeImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TriggerProfileTypeImpl.java index 97a2f1c740c..89b87819063 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TriggerProfileTypeImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/TriggerProfileTypeImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/profiles/i18n/ProfileI18nUtil.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/i18n/ProfileI18nUtil.java index c5f750253d7..115116bbb48 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/i18n/ProfileI18nUtil.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/profiles/i18n/ProfileI18nUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +27,7 @@ * A utility service which localizes {@link Profile}s. * Falls back to a localized {@link ProfileType} for label and description when not given otherwise. * - * @see {@link ProfileTypeI18nLocalizationService} + * @see org.openhab.core.thing.profiles.i18n.ProfileTypeI18nLocalizationService * * @author Christoph Weitkamp - Initial contribution */ diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/type/AbstractChannelTypeBuilder.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/type/AbstractChannelTypeBuilder.java index ad504b15a14..6e18770a90e 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/type/AbstractChannelTypeBuilder.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/type/AbstractChannelTypeBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.util.HashSet; import java.util.Set; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.thing.type.ChannelType; @@ -30,7 +31,7 @@ */ @NonNullByDefault @SuppressWarnings("unchecked") -abstract class AbstractChannelTypeBuilder> implements ChannelTypeBuilder { +abstract class AbstractChannelTypeBuilder<@NonNull T extends ChannelTypeBuilder> implements ChannelTypeBuilder { protected final ChannelTypeUID channelTypeUID; protected final String label; diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/type/StateChannelTypeBuilderImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/type/StateChannelTypeBuilderImpl.java index af26008cf87..806fa761b24 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/type/StateChannelTypeBuilderImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/type/StateChannelTypeBuilderImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -35,7 +35,7 @@ public class StateChannelTypeBuilderImpl extends AbstractChannelTypeBuilder implements StateChannelTypeBuilder { - private class StateChannelTypeImpl extends ChannelType { + private static class StateChannelTypeImpl extends ChannelType { private StateChannelTypeImpl(ChannelTypeUID uid, boolean advanced, String itemType, String label, @Nullable String description, @Nullable String category, @Nullable Set tags, @Nullable StateDescription state, @Nullable CommandDescription commandDescription, diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/type/TriggerChannelTypeBuilderImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/type/TriggerChannelTypeBuilderImpl.java index b16c6bafc4e..226d0271ca9 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/type/TriggerChannelTypeBuilderImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/type/TriggerChannelTypeBuilderImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +32,7 @@ public class TriggerChannelTypeBuilderImpl extends AbstractChannelTypeBuilder implements TriggerChannelTypeBuilder { - private class TriggerChannelTypeImpl extends ChannelType { + private static class TriggerChannelTypeImpl extends ChannelType { TriggerChannelTypeImpl(ChannelTypeUID uid, boolean advanced, String label, @Nullable String description, @Nullable String category, @Nullable Set tags, @Nullable EventDescription event, @Nullable URI configDescriptionURI) throws IllegalArgumentException { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/update/RemoveChannelInstructionImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/update/RemoveChannelInstructionImpl.java index b2d54e02c8d..84463c12324 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/update/RemoveChannelInstructionImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/update/RemoveChannelInstructionImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/update/ThingUpdateInstruction.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/update/ThingUpdateInstruction.java index a6955b704ee..3584a0f61f9 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/update/ThingUpdateInstruction.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/update/ThingUpdateInstruction.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/update/ThingUpdateInstructionReader.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/update/ThingUpdateInstructionReader.java index a56f104399b..2db22ba1526 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/update/ThingUpdateInstructionReader.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/update/ThingUpdateInstructionReader.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/update/ThingUpdateInstructionReaderImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/update/ThingUpdateInstructionReaderImpl.java index 8cb809bd527..7294584167d 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/update/ThingUpdateInstructionReaderImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/update/ThingUpdateInstructionReaderImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/internal/update/UpdateChannelInstructionImpl.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/update/UpdateChannelInstructionImpl.java index 753ed5f3a06..9f626cffaad 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/update/UpdateChannelInstructionImpl.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/internal/update/UpdateChannelInstructionImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/link/AbstractLink.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/AbstractLink.java index 952a30edb07..e843a9def36 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/AbstractLink.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/AbstractLink.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -45,12 +45,12 @@ public static String getIDFor(String itemName, UID uid) { * @param itemName the item name for the link * @throws IllegalArgumentException if the item name is invalid */ - public AbstractLink(String itemName) { + protected AbstractLink(String itemName) { ItemUtil.assertValidItemName(itemName); this.itemName = itemName; } - AbstractLink() { + protected AbstractLink() { this.itemName = null; } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/AbstractLinkRegistry.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/AbstractLinkRegistry.java index f58b920b5e9..ac4ef919ab1 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/AbstractLinkRegistry.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/AbstractLinkRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.stream.Collectors; @@ -73,18 +74,10 @@ private void toLinkAdded(final L element) { try { Set set; - set = itemNameToLink.get(itemName); - if (set == null) { - set = new HashSet<>(); - itemNameToLink.put(itemName, set); - } + set = Objects.requireNonNull(itemNameToLink.computeIfAbsent(itemName, k -> new HashSet<>())); set.add(element); - set = linkedUidToLink.get(linkedUid); - if (set == null) { - set = new HashSet<>(); - linkedUidToLink.put(linkedUid, set); - } + set = Objects.requireNonNull(linkedUidToLink.computeIfAbsent(linkedUid, k -> new HashSet<>())); set.add(element); } finally { toLinkLock.writeLock().unlock(); @@ -185,7 +178,7 @@ public Set getLinkedItemNames(final UID uid) { if (forLinkedUID == null) { return Set.of(); } - return forLinkedUID.stream().map(link -> link.getItemName()).collect(Collectors.toSet()); + return forLinkedUID.stream().map(AbstractLink::getItemName).collect(Collectors.toSet()); } finally { toLinkLock.readLock().unlock(); } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/ItemChannelLink.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/ItemChannelLink.java index 274f0288708..47106ad7f2a 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/ItemChannelLink.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/ItemChannelLink.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/link/ItemChannelLinkProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/ItemChannelLinkProvider.java index bf40984d1ca..26e60d0ca0e 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/ItemChannelLinkProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/ItemChannelLinkProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/link/ItemChannelLinkRegistry.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/ItemChannelLinkRegistry.java index 58d08cfb5ae..d8466213aba 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/ItemChannelLinkRegistry.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/ItemChannelLinkRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/link/ManagedItemChannelLinkProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/ManagedItemChannelLinkProvider.java index ec8392fc47e..f516b644332 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/ManagedItemChannelLinkProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/ManagedItemChannelLinkProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/link/dto/AbstractLinkDTO.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/dto/AbstractLinkDTO.java index a71119bccd6..72d381e6793 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/dto/AbstractLinkDTO.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/dto/AbstractLinkDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +27,7 @@ public abstract class AbstractLinkDTO { protected AbstractLinkDTO() { } - public AbstractLinkDTO(String itemName) { + protected AbstractLinkDTO(String itemName) { this.itemName = itemName; } } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/dto/ItemChannelLinkDTO.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/dto/ItemChannelLinkDTO.java index 1d9e5f51744..fc32d2942bb 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/dto/ItemChannelLinkDTO.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/dto/ItemChannelLinkDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/link/events/AbstractItemChannelLinkRegistryEvent.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/events/AbstractItemChannelLinkRegistryEvent.java index 860e6f7f93f..173ab4ccbe1 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/events/AbstractItemChannelLinkRegistryEvent.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/events/AbstractItemChannelLinkRegistryEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 @@ public abstract class AbstractItemChannelLinkRegistryEvent extends AbstractEvent private final ItemChannelLinkDTO link; - public AbstractItemChannelLinkRegistryEvent(String topic, String payload, ItemChannelLinkDTO link) { + protected AbstractItemChannelLinkRegistryEvent(String topic, String payload, ItemChannelLinkDTO link) { super(topic, payload, null); this.link = link; } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/events/ItemChannelLinkAddedEvent.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/events/ItemChannelLinkAddedEvent.java index c8062b5f40a..f9c767ba788 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/events/ItemChannelLinkAddedEvent.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/events/ItemChannelLinkAddedEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/link/events/ItemChannelLinkRemovedEvent.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/events/ItemChannelLinkRemovedEvent.java index 61d101ea6bf..e299c5ea2ac 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/events/ItemChannelLinkRemovedEvent.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/events/ItemChannelLinkRemovedEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/link/events/LinkEventFactory.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/events/LinkEventFactory.java index 4925e2131c7..eb675d3a7c4 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/events/LinkEventFactory.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/link/events/LinkEventFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/Profile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/Profile.java index d48e9e38611..73d997e46eb 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/Profile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/Profile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/ProfileAdvisor.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileAdvisor.java index 3718041a977..a0d8604d3c7 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileAdvisor.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileAdvisor.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/ProfileCallback.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileCallback.java index 2e0eeecd993..f7f98b1b9c8 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileCallback.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileCallback.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/ProfileContext.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileContext.java index ba1e909f75b..47f7226fdc1 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileContext.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileContext.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/ProfileFactory.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileFactory.java index bff722a192a..0e0570bd1c9 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileFactory.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/ProfileType.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileType.java index bf1fa4c38cf..00619458f8a 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileType.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/ProfileTypeBuilder.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileTypeBuilder.java index f4a110ff978..b8e4fd1767f 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileTypeBuilder.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileTypeBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.util.Collection; import java.util.HashSet; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.thing.internal.profiles.StateProfileTypeImpl; import org.openhab.core.thing.internal.profiles.TriggerProfileTypeImpl; @@ -31,7 +32,7 @@ * @param the concrete {@link ProfileType} sub-interface. */ @NonNullByDefault -public final class ProfileTypeBuilder { +public final class ProfileTypeBuilder<@NonNull T extends ProfileType> { @FunctionalInterface private interface ProfileTypeFactory { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileTypeProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileTypeProvider.java index 389e7dd5312..ce271ff99bf 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileTypeProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileTypeProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/ProfileTypeRegistry.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileTypeRegistry.java index 1cbff58443c..d22af0890e9 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileTypeRegistry.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileTypeRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/ProfileTypeUID.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileTypeUID.java index 09796ad3021..be6145dffec 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileTypeUID.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/ProfileTypeUID.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/StateProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/StateProfile.java index 41830e558d1..d6d8c2e277b 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/StateProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/StateProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/StateProfileType.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/StateProfileType.java index d84b8929183..5ef1c501140 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/StateProfileType.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/StateProfileType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/SystemProfiles.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/SystemProfiles.java index 5b533cf9567..ba39f21b76c 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/SystemProfiles.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/SystemProfiles.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/TimeSeriesProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/TimeSeriesProfile.java index 9625069bcce..fca262f1761 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/TimeSeriesProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/TimeSeriesProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/TriggerProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/TriggerProfile.java index 609b881fa1f..0e4831b1848 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/TriggerProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/TriggerProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/TriggerProfileType.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/TriggerProfileType.java index 7d1cb2831ce..e0f3b2d9dcf 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/TriggerProfileType.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/TriggerProfileType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/dto/ProfileTypeDTO.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/dto/ProfileTypeDTO.java index 4e92ae8c81c..059b91e8c0b 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/dto/ProfileTypeDTO.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/dto/ProfileTypeDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/dto/ProfileTypeDTOMapper.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/dto/ProfileTypeDTOMapper.java index 18a6606191b..95c9ba63687 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/dto/ProfileTypeDTOMapper.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/dto/ProfileTypeDTOMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/profiles/i18n/ProfileTypeI18nLocalizationService.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/i18n/ProfileTypeI18nLocalizationService.java index 76e8a15ea8a..a1da0812e5c 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/i18n/ProfileTypeI18nLocalizationService.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/profiles/i18n/ProfileTypeI18nLocalizationService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/AbstractDescriptionType.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/AbstractDescriptionType.java index 9e4bdb71b78..56e59303e01 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/AbstractDescriptionType.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/AbstractDescriptionType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -49,7 +49,7 @@ public abstract class AbstractDescriptionType implements Identifiable { * @param configDescriptionURI the {@link URI} that references the {@link ConfigDescription} of this type * @throws IllegalArgumentException if the UID is null, or the label is null or empty */ - public AbstractDescriptionType(UID uid, String label, @Nullable String description, + protected AbstractDescriptionType(UID uid, String label, @Nullable String description, @Nullable URI configDescriptionURI) throws IllegalArgumentException { if (label.isEmpty()) { throw new IllegalArgumentException("The label must neither be null nor empty!"); diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/AutoUpdatePolicy.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/AutoUpdatePolicy.java index 085eceeba84..620b47d07aa 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/AutoUpdatePolicy.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/AutoUpdatePolicy.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/BridgeType.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/BridgeType.java index 98b77684acb..a4e0fbdfb0d 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/BridgeType.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/BridgeType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -39,9 +39,7 @@ public class BridgeType extends ThingType { /** * A new instance of BridgeType. * - * @see ThingType(uid, supportedBridgeTypeUIDs, label, description, category, listed, representationProperty, - * channelDefinitions, channelGroupDefinitions, properties, configDescriptionURI, - * extensibleChannelTypeIds) + * @see ThingType#ThingType(ThingTypeUID, List, String, String, String, boolean, String, List, List, Map, URI, List) * * @param uid the unique identifier which identifies this Thing type within the overall system * (must neither be null, nor empty) @@ -60,7 +58,7 @@ public class BridgeType extends ThingType { * @param properties the properties this Thing type provides (could be null) * @param configDescriptionURI the link to the concrete ConfigDescription (could be null) * @param extensibleChannelTypeIds the channel-type ids this thing-type is extensible with (could be null or empty). - * @throws IllegalArgumentException if the UID is null or empty, or the the meta information is null + * @throws IllegalArgumentException if the UID is null or empty, or the meta information is null */ BridgeType(ThingTypeUID uid, @Nullable List supportedBridgeTypeUIDs, String label, @Nullable String description, @Nullable String category, boolean listed, diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelDefinition.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelDefinition.java index c40416a1284..33f012a45bf 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelDefinition.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelDefinition.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/ChannelDefinitionBuilder.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelDefinitionBuilder.java index f5cc7dba9b9..170e5de3538 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelDefinitionBuilder.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelDefinitionBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupDefinition.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupDefinition.java index 9407a6fcc65..8136bf4f1aa 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupDefinition.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupDefinition.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupType.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupType.java index 0084c87d525..6c00f06cc3b 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupType.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupTypeBuilder.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupTypeBuilder.java index e042ba5ed92..97f87154add 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupTypeBuilder.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupTypeBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupTypeProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupTypeProvider.java index 8e95acf3f58..09a2cc3f800 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupTypeProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupTypeProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupTypeRegistry.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupTypeRegistry.java index 067787f683a..aeb094faec8 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupTypeRegistry.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupTypeRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupTypeUID.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupTypeUID.java index a7e27a10912..fc8926fe54f 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupTypeUID.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelGroupTypeUID.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/ChannelKind.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelKind.java index f59ba31d10c..01b88e61ccd 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelKind.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelKind.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/ChannelType.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelType.java index 11930aab2be..492ff5f8cee 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelType.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/ChannelTypeBuilder.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelTypeBuilder.java index 979564e5bf2..5fbc703a75b 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelTypeBuilder.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelTypeBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 @@ import java.net.URI; import java.util.Collection; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.thing.internal.type.StateChannelTypeBuilderImpl; import org.openhab.core.thing.internal.type.TriggerChannelTypeBuilderImpl; @@ -25,7 +26,7 @@ * @author Stefan Triller - Initial contribution */ @NonNullByDefault -public interface ChannelTypeBuilder> { +public interface ChannelTypeBuilder<@NonNull T extends ChannelTypeBuilder> { /** * Specify whether this is an advanced channel, default is false * diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelTypeProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelTypeProvider.java index 8c2b0a315bf..57226e59690 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelTypeProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelTypeProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/ChannelTypeRegistry.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelTypeRegistry.java index 98e0e8857a7..7219d6fa4e6 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelTypeRegistry.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelTypeRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/ChannelTypeUID.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelTypeUID.java index bafd39676fa..3cb0b7a8b9b 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelTypeUID.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ChannelTypeUID.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/DynamicCommandDescriptionProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/DynamicCommandDescriptionProvider.java index 876a38ba9ea..5fd8786fc48 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/DynamicCommandDescriptionProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/DynamicCommandDescriptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/DynamicStateDescriptionProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/DynamicStateDescriptionProvider.java index d562f446893..ba6e9d817a6 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/DynamicStateDescriptionProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/DynamicStateDescriptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/StateChannelTypeBuilder.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/StateChannelTypeBuilder.java index d70192c4ad0..749c64f8892 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/StateChannelTypeBuilder.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/StateChannelTypeBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/ThingType.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ThingType.java index 80bf075a3fe..773cf71893f 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ThingType.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ThingType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/ThingTypeBuilder.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ThingTypeBuilder.java index 72dc673c7d8..522bb28d50d 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ThingTypeBuilder.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ThingTypeBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/ThingTypeRegistry.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ThingTypeRegistry.java index e4d3cf16404..3b9fe416b69 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ThingTypeRegistry.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/ThingTypeRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/type/TriggerChannelTypeBuilder.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/TriggerChannelTypeBuilder.java index bfacdb6e90f..9494e0112ad 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/TriggerChannelTypeBuilder.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/type/TriggerChannelTypeBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/util/ThingHandlerHelper.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/util/ThingHandlerHelper.java index ed9fc96af58..c9a31a9ffd3 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/util/ThingHandlerHelper.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/util/ThingHandlerHelper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/util/ThingHelper.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/util/ThingHelper.java index 16a90ebeaf7..a705247d40c 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/util/ThingHelper.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/util/ThingHelper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/util/ThingWebClientUtil.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/util/ThingWebClientUtil.java index 98632fd9b7f..9cf92a8fba7 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/util/ThingWebClientUtil.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/util/ThingWebClientUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/AbstractDescriptionTypeConverter.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/AbstractDescriptionTypeConverter.java index 323b8d2b4c2..40559a17adf 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/AbstractDescriptionTypeConverter.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/AbstractDescriptionTypeConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -54,7 +54,7 @@ public abstract class AbstractDescriptionTypeConverter extends GenericUnmarsh * @param clazz the class of the result type (must not be null) * @param type the name of the type (e.g. "thing-type", "channel-type") */ - public AbstractDescriptionTypeConverter(Class clazz, String type) { + protected AbstractDescriptionTypeConverter(Class clazz, String type) { super(clazz); this.type = type; this.attributeMapValidator = new ConverterAttributeMapValidator(new String[][] { { "id", "true" } }); diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/BridgeTypeConverter.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/BridgeTypeConverter.java index 152e347f655..0385229791f 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/BridgeTypeConverter.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/BridgeTypeConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/BridgeTypeXmlResult.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/BridgeTypeXmlResult.java index 09264d3bf9a..23546e7203b 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/BridgeTypeXmlResult.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/BridgeTypeXmlResult.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelConverter.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelConverter.java index 9e53c2929a7..9cb5de1cb98 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelConverter.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelGroupTypeConverter.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelGroupTypeConverter.java index d5fb71fcd80..41ba93ffe8d 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelGroupTypeConverter.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelGroupTypeConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelGroupTypeXmlResult.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelGroupTypeXmlResult.java index da7aca5672d..71e795305fb 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelGroupTypeXmlResult.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelGroupTypeXmlResult.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ArrayList; import java.util.List; -import java.util.Map; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -29,7 +28,7 @@ * The {@link ChannelGroupTypeXmlResult} is an intermediate XML conversion result object which * contains all parts of a {@link ChannelGroupType} object. *

        - * To create a concrete {@link ChannelGroupType} object, the method {@link #toChannelGroupType(Map)} must be called. + * To create a concrete {@link ChannelGroupType} object, the method {@link #toChannelGroupType()} must be called. * * @author Michael Grammling - Initial contribution * @author Chris Jackson - Updated to support channel properties diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelTypeConverter.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelTypeConverter.java index d6a7b404bd7..052f1085021 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelTypeConverter.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelTypeConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelTypeXmlResult.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelTypeXmlResult.java index 7129aa5806f..79b2123b80f 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelTypeXmlResult.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelTypeXmlResult.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelXmlResult.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelXmlResult.java index 1957f25e69c..63f5ce39b37 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelXmlResult.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ChannelXmlResult.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/CommandDescriptionConverter.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/CommandDescriptionConverter.java index 2363b5c78fb..f4c32b13068 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/CommandDescriptionConverter.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/CommandDescriptionConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/EventDescriptionConverter.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/EventDescriptionConverter.java index 883adf05c29..59fcaecad08 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/EventDescriptionConverter.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/EventDescriptionConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/StateDescriptionConverter.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/StateDescriptionConverter.java index 01be3a022b3..d9a4167cd50 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/StateDescriptionConverter.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/StateDescriptionConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +73,7 @@ public StateDescriptionConverter() { private boolean toBoolean(Map attributes, String attribute, boolean defaultValue) { String attrValueText = attributes.get(attribute); - return attrValueText == null ? defaultValue : Boolean.valueOf(attrValueText); + return attrValueText == null ? defaultValue : Boolean.parseBoolean(attrValueText); } private List toListOfChannelState(NodeList nodeList) throws ConversionException { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingDescriptionConverter.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingDescriptionConverter.java index 80d72bcb965..39ec8fb23e0 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingDescriptionConverter.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingDescriptionConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingDescriptionList.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingDescriptionList.java index c13b1054879..840add51a94 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingDescriptionList.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingDescriptionList.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingDescriptionReader.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingDescriptionReader.java index 1b01f98a260..194b89ec7ba 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingDescriptionReader.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingDescriptionReader.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingTypeConverter.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingTypeConverter.java index 266af7c2bf6..49469480404 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingTypeConverter.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingTypeConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -80,10 +80,9 @@ protected ThingTypeConverter(Class clazz, String type) { @SuppressWarnings("unchecked") protected List[] getChannelTypeReferenceObjects(NodeIterator nodeIterator) throws ConversionException { - List channelTypeReferences = null; List channelGroupTypeReferences = null; - - channelTypeReferences = (List) nodeIterator.nextList("channels", false); + List channelTypeReferences = (List) nodeIterator.nextList("channels", + false); if (channelTypeReferences == null) { channelGroupTypeReferences = (List) nodeIterator.nextList("channel-groups", false); } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingTypeXmlProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingTypeXmlProvider.java index fd74c108928..a0d47ef4057 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingTypeXmlProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingTypeXmlProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +43,7 @@ * service at the OSGi service registry. *

        * The {@link ThingTypeXmlProvider} uses an internal cache consisting of {@link #thingTypeRefs}, - * {@link #channelGroupTypeRefs}, {@link #channelGroupTypes} and {@link #channelTypes}. This cache is used to merge + * {@link #channelGroupTypeRefs}, {@link #channelTypeRefs}. This cache is used to merge * first the {@link ChannelType} definitions with the {@link ChannelGroupTypeXmlResult} objects to create valid * {@link ChannelGroupType} objects. After that the {@link ChannelType} and the {@link ChannelGroupType} definitions are * used to merge with the {@link ThingTypeXmlResult} objects to create valid {@link ThingType} objects. After the merge diff --git a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingTypeXmlResult.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingTypeXmlResult.java index fff9c4a816c..d974283d448 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingTypeXmlResult.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingTypeXmlResult.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingXmlConfigDescriptionProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingXmlConfigDescriptionProvider.java index 4575b09f2a4..38356bae982 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingXmlConfigDescriptionProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/ThingXmlConfigDescriptionProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/XmlChannelGroupTypeProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/XmlChannelGroupTypeProvider.java index 76fd0315535..da9f28a7031 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/XmlChannelGroupTypeProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/XmlChannelGroupTypeProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/XmlChannelTypeProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/XmlChannelTypeProvider.java index e5bec3d468b..5ea06a6e344 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/XmlChannelTypeProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/XmlChannelTypeProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/XmlHelper.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/XmlHelper.java index 54922f014d2..c102899d6e6 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/XmlHelper.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/XmlHelper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/main/java/org/openhab/core/thing/xml/internal/XmlThingTypeProvider.java b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/XmlThingTypeProvider.java index fc04f1e25c7..d6d9a620e2f 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/XmlThingTypeProvider.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/xml/internal/XmlThingTypeProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/ChannelGroupUIDTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/ChannelGroupUIDTest.java index dde3f91119a..c98dedbb301 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/ChannelGroupUIDTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/ChannelGroupUIDTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/ChannelTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/ChannelTest.java index 713c4267a03..4d26fdb8128 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/ChannelTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/ChannelTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/ChannelUIDTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/ChannelUIDTest.java index 906351e8882..ead75bf61ea 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/ChannelUIDTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/ChannelUIDTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +21,7 @@ * Tests for class {@link ChannelUID}. * * @author Simon Kaufmann - Initial contribution - * @author Christoph Weitkamp - Changed pattern for validating last segment to contain either a single `#` or none + * @author Christoph Weitkamp - Changed pattern for validating last segment to contain either a single {@code #} or none */ @NonNullByDefault public class ChannelUIDTest { diff --git a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/ManagedThingProviderTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/ManagedThingProviderTest.java index e73508ac38a..eb3b3c66ae4 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/ManagedThingProviderTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/ManagedThingProviderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/ThingUIDTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/ThingUIDTest.java index d3c4e3d91e5..cb236efe13b 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/ThingUIDTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/ThingUIDTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/UIDTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/UIDTest.java index 9fd04170674..d3401df57f2 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/UIDTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/UIDTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/binding/AbstractStorageBasedTypeProviderTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/AbstractStorageBasedTypeProviderTest.java index 3b06e275382..9062ea310e6 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/AbstractStorageBasedTypeProviderTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/AbstractStorageBasedTypeProviderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/binding/BaseDynamicCommandDescriptionProviderTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/BaseDynamicCommandDescriptionProviderTest.java index 9b19fe5ca3e..33b749213df 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/BaseDynamicCommandDescriptionProviderTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/BaseDynamicCommandDescriptionProviderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 @@ public TestDynamicCommandDescriptionProvider() { this.eventPublisher = eventPublisherMock; this.itemChannelLinkRegistry = itemChannelLinkRegistryMock; } - }; + } private @NonNullByDefault({}) TestDynamicCommandDescriptionProvider subject; @@ -86,7 +86,7 @@ public void setCommandOptionsPublishesEvent() { verify(eventPublisherMock, times(1)).post(capture.capture()); Event event = capture.getValue(); - assertTrue(event instanceof ChannelDescriptionChangedEvent); + assertInstanceOf(ChannelDescriptionChangedEvent.class, event); ChannelDescriptionChangedEvent cdce = (ChannelDescriptionChangedEvent) event; assertEquals(CommonChannelDescriptionField.COMMAND_OPTIONS, cdce.getField()); diff --git a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/BaseDynamicStateDescriptionProviderTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/BaseDynamicStateDescriptionProviderTest.java index bc83630c964..e665ecddea4 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/BaseDynamicStateDescriptionProviderTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/BaseDynamicStateDescriptionProviderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 @@ public TestBaseDynamicStateDescriptionProvider() { this.eventPublisher = eventPublisherMock; this.itemChannelLinkRegistry = itemChannelLinkRegistryMock; } - }; + } private @NonNullByDefault({}) BaseDynamicStateDescriptionProvider subject; @@ -86,7 +86,7 @@ public void setStatePatternPublishesEvent() { verify(eventPublisherMock, times(1)).post(capture.capture()); Event event = capture.getValue(); - assertTrue(event instanceof ChannelDescriptionChangedEvent); + assertInstanceOf(ChannelDescriptionChangedEvent.class, event); ChannelDescriptionChangedEvent cdce = (ChannelDescriptionChangedEvent) event; assertEquals(CommonChannelDescriptionField.PATTERN, cdce.getField()); @@ -104,7 +104,7 @@ public void setStateOptionsPublishesEvent() { verify(eventPublisherMock, times(1)).post(capture.capture()); Event event = capture.getValue(); - assertTrue(event instanceof ChannelDescriptionChangedEvent); + assertInstanceOf(ChannelDescriptionChangedEvent.class, event); ChannelDescriptionChangedEvent cdce = (ChannelDescriptionChangedEvent) event; assertEquals(CommonChannelDescriptionField.STATE_OPTIONS, cdce.getField()); diff --git a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/builder/ChannelBuilderTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/builder/ChannelBuilderTest.java index efa439da8e1..f8432662780 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/builder/ChannelBuilderTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/builder/ChannelBuilderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,6 +84,7 @@ public void testChannelBuilderFromChannel() { assertThat(otherChannel.getDescription(), is(channel.getDescription())); assertThat(otherChannel.getKind(), is(channel.getKind())); assertThat(otherChannel.getLabel(), is(channel.getLabel())); + assertThat(otherChannel.getAutoUpdatePolicy(), is(channel.getAutoUpdatePolicy())); assertThat(otherChannel.getProperties().size(), is(channel.getProperties().size())); assertThat(otherChannel.getProperties().get(KEY1), is(channel.getProperties().get(KEY1))); assertThat(otherChannel.getProperties().get(KEY2), is(channel.getProperties().get(KEY2))); diff --git a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/builder/ThingBuilderTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/builder/ThingBuilderTest.java index f4262885596..9800715083b 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/builder/ThingBuilderTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/builder/ThingBuilderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/binding/builder/ThingStatusInfoBuilderTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/builder/ThingStatusInfoBuilderTest.java index 53fe2445e34..81ddbe85b37 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/builder/ThingStatusInfoBuilderTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/builder/ThingStatusInfoBuilderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/binding/generic/ChannelTransformationTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/generic/ChannelTransformationTest.java index d7847b63228..993de4662cb 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/generic/ChannelTransformationTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/generic/ChannelTransformationTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/binding/generic/converter/ConverterTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/generic/converter/ConverterTest.java index 1d5e2e6b24e..229bfa237dc 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/generic/converter/ConverterTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/binding/generic/converter/ConverterTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/dto/ChannelDTOTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/dto/ChannelDTOTest.java index 6246b2b019b..ba81fac0ad6 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/dto/ChannelDTOTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/dto/ChannelDTOTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/dto/ThingDTOTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/dto/ThingDTOTest.java index e98ffd34bdb..dc885e7eb1b 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/dto/ThingDTOTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/dto/ThingDTOTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/events/ThingEventFactoryTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/events/ThingEventFactoryTest.java index 4d758c9b265..ec23985aa46 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/events/ThingEventFactoryTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/events/ThingEventFactoryTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/firmware/FirmwareEventFactoryTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/firmware/FirmwareEventFactoryTest.java index 27ca2d09f38..42aa1ced6e5 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/firmware/FirmwareEventFactoryTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/firmware/FirmwareEventFactoryTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/internal/AutoUpdateManagerTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/AutoUpdateManagerTest.java index 0d3ee49d823..9de710012df 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/AutoUpdateManagerTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/AutoUpdateManagerTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -110,16 +110,16 @@ public void setup() { when(onlineThingMock.getHandler()).thenReturn(handlerMock); when(onlineThingMock.getStatus()).thenReturn(ThingStatus.ONLINE); - when(onlineThingMock.getChannel(eq(CHANNEL_UID_ONLINE_1.getId()))) + when(onlineThingMock.getChannel(eq(CHANNEL_UID_ONLINE_1))) .thenAnswer(answer -> ChannelBuilder.create(CHANNEL_UID_ONLINE_1, CoreItemFactory.STRING) .withAutoUpdatePolicy(policies.get(CHANNEL_UID_ONLINE_1)).build()); - when(onlineThingMock.getChannel(eq(CHANNEL_UID_ONLINE_2.getId()))) + when(onlineThingMock.getChannel(eq(CHANNEL_UID_ONLINE_2))) .thenAnswer(answer -> ChannelBuilder.create(CHANNEL_UID_ONLINE_2, CoreItemFactory.STRING) .withAutoUpdatePolicy(policies.get(CHANNEL_UID_ONLINE_2)).build()); when(offlineThingMock.getHandler()).thenReturn(handlerMock); when(offlineThingMock.getStatus()).thenReturn(ThingStatus.OFFLINE); - when(offlineThingMock.getChannel(eq(CHANNEL_UID_OFFLINE_1.getId()))) + when(offlineThingMock.getChannel(eq(CHANNEL_UID_OFFLINE_1))) .thenAnswer(answer -> ChannelBuilder.create(CHANNEL_UID_OFFLINE_1, CoreItemFactory.STRING) .withAutoUpdatePolicy(policies.get(CHANNEL_UID_OFFLINE_1)).build()); diff --git a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/ThingImplTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/ThingImplTest.java index caa229f588f..b4023a8e946 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/ThingImplTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/ThingImplTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/internal/ThingManagerImplTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/ThingManagerImplTest.java index bf635ce2c29..1705e4bbe41 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/ThingManagerImplTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/ThingManagerImplTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/internal/binding/generic/converter/AbstractTransformingItemConverterTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/binding/generic/converter/AbstractTransformingItemConverterTest.java index 08207319d4a..bf4725b2f96 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/binding/generic/converter/AbstractTransformingItemConverterTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/binding/generic/converter/AbstractTransformingItemConverterTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/internal/firmware/ProgressCallbackTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/firmware/ProgressCallbackTest.java index 1cee26b1f24..42da05c6e6a 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/firmware/ProgressCallbackTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/firmware/ProgressCallbackTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -382,7 +382,7 @@ private void assertThatUpdateResultEventIsValid(Event event, @Nullable String ex assertThat(fpiEvent.getFirmwareUpdateResultInfo().getResult(), is(expectedResult)); } - class DummyFirmwareHandler implements FirmwareUpdateHandler { + static class DummyFirmwareHandler implements FirmwareUpdateHandler { @Override public Thing getThing() { diff --git a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/RawButtonOnOffSwitchProfileTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/RawButtonOnOffSwitchProfileTest.java index 31aad4c7287..354a0870dd3 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/RawButtonOnOffSwitchProfileTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/RawButtonOnOffSwitchProfileTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemDefaultProfileTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemDefaultProfileTest.java index 720f0008515..6e9a4c65ee5 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemDefaultProfileTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemDefaultProfileTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemFollowProfileTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemFollowProfileTest.java index 4ef34b1f2ae..9a2ba78407c 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemFollowProfileTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemFollowProfileTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemHysteresisStateProfileTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemHysteresisStateProfileTest.java index 9e323b367dd..069b09468f8 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemHysteresisStateProfileTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemHysteresisStateProfileTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemOffsetProfileTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemOffsetProfileTest.java index 944544f1369..abf288d80da 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemOffsetProfileTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemOffsetProfileTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemRangeStateProfileTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemRangeStateProfileTest.java index c623a0161b4..a7f3a01a7c2 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemRangeStateProfileTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/SystemRangeStateProfileTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/internal/profiles/TimestampOffsetProfileTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/TimestampOffsetProfileTest.java index 6fe066cb993..1ba18de7969 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/TimestampOffsetProfileTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/TimestampOffsetProfileTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/internal/profiles/TimestampProfileTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/TimestampProfileTest.java index c52cdc8abe9..988d7d1cdb7 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/TimestampProfileTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/TimestampProfileTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/internal/profiles/TimestampTriggerProfileTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/TimestampTriggerProfileTest.java index 5d306335528..3275c57f808 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/TimestampTriggerProfileTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/TimestampTriggerProfileTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/internal/profiles/ToggleProfileTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/ToggleProfileTest.java index 543aa911bd1..e5d62a793fc 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/ToggleProfileTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/ToggleProfileTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/internal/profiles/TriggerEventStringProfileTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/TriggerEventStringProfileTest.java index 9a73082f348..3e1407ce207 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/TriggerEventStringProfileTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/internal/profiles/TriggerEventStringProfileTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -39,7 +39,7 @@ public class TriggerEventStringProfileTest { @Test public void testEventStringItem() { - TriggerProfile profile = new TriggerEventStringProfile((callbackMock)); + TriggerProfile profile = new TriggerEventStringProfile(callbackMock); profile.onTriggerFromHandler(CommonTriggerEvents.PRESSED); verify(callbackMock, times(1)).sendCommand(eq(new StringType(CommonTriggerEvents.PRESSED))); } diff --git a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/link/events/LinkEventFactoryTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/link/events/LinkEventFactoryTest.java index c80c6014970..0983870c1be 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/link/events/LinkEventFactoryTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/link/events/LinkEventFactoryTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 @@ import com.google.gson.Gson; /** - * {@link LinkEventFactoryTests} tests the {@link LinkEventFactory}. + * {@link LinkEventFactoryTest} tests the {@link LinkEventFactory}. * * @author Christoph Weitkamp - Initial contribution */ diff --git a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/type/ChannelGroupTypeBuilderTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/type/ChannelGroupTypeBuilderTest.java index 53d8cf04f8f..1f5f04d73af 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/type/ChannelGroupTypeBuilderTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/type/ChannelGroupTypeBuilderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/type/ChannelTypeBuilderTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/type/ChannelTypeBuilderTest.java index aed6debab32..f999e787609 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/type/ChannelTypeBuilderTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/type/ChannelTypeBuilderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/type/ThingTypeBuilderTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/type/ThingTypeBuilderTest.java index 5cbdba010e6..5f24027a6e3 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/type/ThingTypeBuilderTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/type/ThingTypeBuilderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/util/ThingHandlerHelperTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/util/ThingHandlerHelperTest.java index dffacf57c4f..ec436b7fcc2 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/util/ThingHandlerHelperTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/util/ThingHandlerHelperTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/util/ThingHelperTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/util/ThingHelperTest.java index 167d2406cd3..c421adba474 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/util/ThingHelperTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/util/ThingHelperTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/util/ThingWebClientUtilTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/util/ThingWebClientUtilTest.java index b142fb25d39..0c261cb742f 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/util/ThingWebClientUtilTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/util/ThingWebClientUtilTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/xml/internal/ThingDescriptionReaderTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/xml/internal/ThingDescriptionReaderTest.java index 2efcae6af11..7493712cb2d 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/xml/internal/ThingDescriptionReaderTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/xml/internal/ThingDescriptionReaderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.thing/src/test/java/org/openhab/core/thing/xml/internal/XmlHelperTest.java b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/xml/internal/XmlHelperTest.java index 7fd2e8f1a38..50b7955cd84 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/xml/internal/XmlHelperTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/openhab/core/thing/xml/internal/XmlHelperTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.transform/pom.xml b/bundles/org.openhab.core.transform/pom.xml index 19f6b78fdb4..d48685af628 100644 --- a/bundles/org.openhab.core.transform/pom.xml +++ b/bundles/org.openhab.core.transform/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.transform diff --git a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/AbstractFileTransformationService.java b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/AbstractFileTransformationService.java index 91e35fc936a..c9e230aee07 100644 --- a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/AbstractFileTransformationService.java +++ b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/AbstractFileTransformationService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,7 +188,7 @@ private synchronized WatchService getWatchService() throws TransformationExcepti } private void watchSubDirectory(String subDirectory, final WatchService watchService) { - if (watchedDirectories.indexOf(subDirectory) == -1) { + if (!watchedDirectories.contains(subDirectory)) { String watchedDirectory = getSourcePath() + subDirectory; Path transformFilePath = Paths.get(watchedDirectory); try { @@ -298,7 +298,7 @@ protected List getFilenames(String[] validExtensions) { return Arrays.stream(path.listFiles(new FileExtensionsFilter(validExtensions))).map(File::getName).toList(); } - protected class FileExtensionsFilter implements FilenameFilter { + protected static class FileExtensionsFilter implements FilenameFilter { private final String[] validExtensions; diff --git a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/FileTransformationProvider.java b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/FileTransformationProvider.java index 4fd1213ef8b..dfe38dc5337 100644 --- a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/FileTransformationProvider.java +++ b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/FileTransformationProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.transform/src/main/java/org/openhab/core/transform/ManagedTransformationProvider.java b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/ManagedTransformationProvider.java index a3495a0333d..70d13c6914f 100644 --- a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/ManagedTransformationProvider.java +++ b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/ManagedTransformationProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.transform/src/main/java/org/openhab/core/transform/Transformation.java b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/Transformation.java index 77a64288dc5..2ae602c0152 100644 --- a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/Transformation.java +++ b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/Transformation.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.transform/src/main/java/org/openhab/core/transform/TransformationException.java b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/TransformationException.java index c194899b84e..86b2968ede2 100644 --- a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/TransformationException.java +++ b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/TransformationException.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.transform/src/main/java/org/openhab/core/transform/TransformationHelper.java b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/TransformationHelper.java index 94e953d7253..ef94463833f 100644 --- a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/TransformationHelper.java +++ b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/TransformationHelper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.transform/src/main/java/org/openhab/core/transform/TransformationProvider.java b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/TransformationProvider.java index 716538da54b..efc2a7057e1 100644 --- a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/TransformationProvider.java +++ b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/TransformationProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.transform/src/main/java/org/openhab/core/transform/TransformationRegistry.java b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/TransformationRegistry.java index ae5ab16cfe8..de4d6b13aab 100644 --- a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/TransformationRegistry.java +++ b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/TransformationRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.transform/src/main/java/org/openhab/core/transform/TransformationService.java b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/TransformationService.java index f018a3a4aee..aedaced12ce 100644 --- a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/TransformationService.java +++ b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/TransformationService.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.transform/src/main/java/org/openhab/core/transform/actions/Transformation.java b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/actions/Transformation.java index c4674ec2db9..018b81f15b1 100644 --- a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/actions/Transformation.java +++ b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/actions/Transformation.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.transform/src/main/java/org/openhab/core/transform/internal/TransformationActivator.java b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/internal/TransformationActivator.java index e791f8235e5..de32ce63c1e 100644 --- a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/internal/TransformationActivator.java +++ b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/internal/TransformationActivator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.transform/src/main/java/org/openhab/core/transform/internal/TransformationRegistryImpl.java b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/internal/TransformationRegistryImpl.java index f6b4b0aba3a..b7c5dd4e1ea 100644 --- a/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/internal/TransformationRegistryImpl.java +++ b/bundles/org.openhab.core.transform/src/main/java/org/openhab/core/transform/internal/TransformationRegistryImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.transform/src/test/java/org/openhab/core/transform/FileTransformationProviderTest.java b/bundles/org.openhab.core.transform/src/test/java/org/openhab/core/transform/FileTransformationProviderTest.java index 0deab6bd692..2cd9f519250 100644 --- a/bundles/org.openhab.core.transform/src/test/java/org/openhab/core/transform/FileTransformationProviderTest.java +++ b/bundles/org.openhab.core.transform/src/test/java/org/openhab/core/transform/FileTransformationProviderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.transform/src/test/java/org/openhab/core/transform/ManagedTransformationProviderTest.java b/bundles/org.openhab.core.transform/src/test/java/org/openhab/core/transform/ManagedTransformationProviderTest.java index b1774e3dea7..c54095cfb7b 100644 --- a/bundles/org.openhab.core.transform/src/test/java/org/openhab/core/transform/ManagedTransformationProviderTest.java +++ b/bundles/org.openhab.core.transform/src/test/java/org/openhab/core/transform/ManagedTransformationProviderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.transform/src/test/java/org/openhab/core/transform/actions/TransformationTest.java b/bundles/org.openhab.core.transform/src/test/java/org/openhab/core/transform/actions/TransformationTest.java index 6496c05936b..8a7a9f8f82a 100644 --- a/bundles/org.openhab.core.transform/src/test/java/org/openhab/core/transform/actions/TransformationTest.java +++ b/bundles/org.openhab.core.transform/src/test/java/org/openhab/core/transform/actions/TransformationTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.transform/src/test/java/org/openhab/core/transform/internal/TransformationRegistryImplTest.java b/bundles/org.openhab.core.transform/src/test/java/org/openhab/core/transform/internal/TransformationRegistryImplTest.java index 610279bd816..880212b5554 100644 --- a/bundles/org.openhab.core.transform/src/test/java/org/openhab/core/transform/internal/TransformationRegistryImplTest.java +++ b/bundles/org.openhab.core.transform/src/test/java/org/openhab/core/transform/internal/TransformationRegistryImplTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui.icon/pom.xml b/bundles/org.openhab.core.ui.icon/pom.xml index 25dbb67d649..56191058617 100644 --- a/bundles/org.openhab.core.ui.icon/pom.xml +++ b/bundles/org.openhab.core.ui.icon/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.ui.icon diff --git a/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/AbstractResourceIconProvider.java b/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/AbstractResourceIconProvider.java index 3b0ee6e2b0a..64241138010 100644 --- a/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/AbstractResourceIconProvider.java +++ b/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/AbstractResourceIconProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -45,7 +45,7 @@ public abstract class AbstractResourceIconProvider implements IconProvider { protected final TranslationProvider i18nProvider; - public AbstractResourceIconProvider(final TranslationProvider i18nProvider) { + protected AbstractResourceIconProvider(final TranslationProvider i18nProvider) { this.i18nProvider = i18nProvider; } @@ -88,9 +88,9 @@ public Set getIconSets() { } else { // let's treat all percentage-based categories try { - Double stateAsDouble = Double.valueOf(iconState); + double stateAsDouble = Double.parseDouble(iconState); if (stateAsDouble >= 0 && stateAsDouble <= 100) { - for (int i = stateAsDouble.intValue(); i >= 0; i--) { + for (int i = (int) stateAsDouble; i >= 0; i--) { String resourceWithNumberState = category.toLowerCase() + "-" + i + "." + format.toString().toLowerCase(); if (hasResource(iconSetId, resourceWithNumberState)) { diff --git a/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/IconProvider.java b/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/IconProvider.java index 1974d719b5b..ae766a09f56 100644 --- a/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/IconProvider.java +++ b/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/IconProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui.icon/src/main/java/org/openhab/core/ui/icon/IconSet.java b/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/IconSet.java index 5275954c805..29af8aa364a 100644 --- a/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/IconSet.java +++ b/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/IconSet.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui.icon/src/main/java/org/openhab/core/ui/icon/internal/CustomIconProvider.java b/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/internal/CustomIconProvider.java index aa69675aafb..2a41af46633 100644 --- a/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/internal/CustomIconProvider.java +++ b/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/internal/CustomIconProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui.icon/src/main/java/org/openhab/core/ui/icon/internal/IconServlet.java b/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/internal/IconServlet.java index 1cf34e79965..7fbaa2fc0a7 100644 --- a/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/internal/IconServlet.java +++ b/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/internal/IconServlet.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui.icon/src/main/java/org/openhab/core/ui/icon/internal/IconSetResource.java b/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/internal/IconSetResource.java index 658ddae8aa3..982a269f49b 100644 --- a/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/internal/IconSetResource.java +++ b/bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/internal/IconSetResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui.icon/src/test/java/org/openhab/core/ui/icon/AbstractResourceIconProviderTest.java b/bundles/org.openhab.core.ui.icon/src/test/java/org/openhab/core/ui/icon/AbstractResourceIconProviderTest.java index c86ec9284cc..d307cb22751 100644 --- a/bundles/org.openhab.core.ui.icon/src/test/java/org/openhab/core/ui/icon/AbstractResourceIconProviderTest.java +++ b/bundles/org.openhab.core.ui.icon/src/test/java/org/openhab/core/ui/icon/AbstractResourceIconProviderTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,17 +82,17 @@ protected boolean hasResource(String iconset, String resourceName) { String state = substringAfterLast(resourceName, "-"); state = substringBeforeLast(state, "."); return "30".equals(state) || "y z".equals(state); - }; + } @Override public Set getIconSets(@Nullable Locale locale) { return Set.of(); - }; + } @Override public Integer getPriority() { return 0; - }; + } }; } diff --git a/bundles/org.openhab.core.ui.icon/src/test/java/org/openhab/core/ui/icon/internal/IconServletTest.java b/bundles/org.openhab.core.ui.icon/src/test/java/org/openhab/core/ui/icon/internal/IconServletTest.java index 84a6f711f6c..ff623ec02a4 100644 --- a/bundles/org.openhab.core.ui.icon/src/test/java/org/openhab/core/ui/icon/internal/IconServletTest.java +++ b/bundles/org.openhab.core.ui.icon/src/test/java/org/openhab/core/ui/icon/internal/IconServletTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -66,7 +66,7 @@ public boolean isReady() { } public String getOutput() { - return new String(outputStream.toByteArray()); + return outputStream.toString(); } public void reset() { diff --git a/bundles/org.openhab.core.ui/pom.xml b/bundles/org.openhab.core.ui/pom.xml index 12834e618f5..a560ae2fa1a 100644 --- a/bundles/org.openhab.core.ui/pom.xml +++ b/bundles/org.openhab.core.ui/pom.xml @@ -7,7 +7,7 @@ org.openhab.core.bundles org.openhab.core.reactor.bundles - 4.1.0-SNAPSHOT + 4.2.0-SNAPSHOT org.openhab.core.ui diff --git a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/chart/ChartProvider.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/chart/ChartProvider.java index 5ea642e32f4..44eac122b12 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/chart/ChartProvider.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/chart/ChartProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui/src/main/java/org/openhab/core/ui/components/RootUIComponent.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/components/RootUIComponent.java index 59665ea747c..677226682cf 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/components/RootUIComponent.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/components/RootUIComponent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 class RootUIComponent extends UIComponent implements Identifiable { String uid; - Set tags = new HashSet(); + Set tags = new HashSet<>(); ConfigDescriptionDTO props; diff --git a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/components/UIComponent.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/components/UIComponent.java index 8c3aa863677..eaf3b70f819 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/components/UIComponent.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/components/UIComponent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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 UIComponent() { public UIComponent(String componentType) { super(); this.component = componentType; - this.config = new HashMap(); + this.config = new HashMap<>(); } /** @@ -136,9 +136,9 @@ public void setSlots(Map> slots) { */ public List addSlot(String slotName) { if (slots == null) { - slots = new HashMap>(); + slots = new HashMap<>(); } - List newSlot = new ArrayList(); + List newSlot = new ArrayList<>(); this.slots.put(slotName, newSlot); return newSlot; diff --git a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/components/UIComponentProvider.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/components/UIComponentProvider.java index 5c507c67a56..624922b403a 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/components/UIComponentProvider.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/components/UIComponentProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui/src/main/java/org/openhab/core/ui/components/UIComponentRegistry.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/components/UIComponentRegistry.java index 033d9f5cdbc..0e1d00b1cdf 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/components/UIComponentRegistry.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/components/UIComponentRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui/src/main/java/org/openhab/core/ui/components/UIComponentRegistryFactory.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/components/UIComponentRegistryFactory.java index 7089a0c65c6..6d04edca730 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/components/UIComponentRegistryFactory.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/components/UIComponentRegistryFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui/src/main/java/org/openhab/core/ui/internal/UIActivator.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/UIActivator.java index 52faea7d99f..b7ebbd358d7 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/UIActivator.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/UIActivator.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui/src/main/java/org/openhab/core/ui/internal/chart/ChartServlet.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/ChartServlet.java index 9464e1c4195..cb03665c91e 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/ChartServlet.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/ChartServlet.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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,15 +12,15 @@ */ package org.openhab.core.ui.internal.chart; -import static java.util.Map.entry; - import java.awt.image.BufferedImage; import java.io.IOException; import java.time.Duration; import java.time.LocalDateTime; +import java.time.Period; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; +import java.time.temporal.TemporalAmount; import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; @@ -69,6 +69,7 @@ * * @author Chris Jackson - Initial contribution * @author Holger Reichert - Support for themes, DPI, legend hiding + * @author Laurent Garnier - Extend support to ISO8601 format for chart period parameter */ @Component(immediate = true, service = { ChartServlet.class, Servlet.class }, configurationPid = "org.openhab.chart", // property = Constants.SERVICE_PID + "=org.openhab.chart") @@ -101,16 +102,6 @@ public class ChartServlet extends HttpServlet { private static final Duration DEFAULT_PERIOD = Duration.ofDays(1); - private static final Map PERIODS = Map.ofEntries( // - entry("h", Duration.ofHours(1)), entry("4h", Duration.ofHours(4)), // - entry("8h", Duration.ofHours(8)), entry("12h", Duration.ofHours(12)), // - entry("D", Duration.ofDays(1)), entry("2D", Duration.ofDays(2)), // - entry("3D", Duration.ofDays(3)), entry("W", Duration.ofDays(7)), // - entry("2W", Duration.ofDays(14)), entry("M", Duration.ofDays(30)), // - entry("2M", Duration.ofDays(60)), entry("4M", Duration.ofDays(120)), // - entry("Y", Duration.ofDays(365))// - ); - protected static final Map CHART_PROVIDERS = new ConcurrentHashMap<>(); @Activate @@ -233,7 +224,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse res) throws Ser } // Read out the parameter period, begin and end and save them. - Duration period = periodParam == null ? DEFAULT_PERIOD : PERIODS.getOrDefault(periodParam, DEFAULT_PERIOD); + TemporalAmount period = convertToTemporalAmount(periodParam, DEFAULT_PERIOD); ZonedDateTime timeBegin = null; ZonedDateTime timeEnd = null; @@ -359,4 +350,37 @@ public void init(@Nullable ServletConfig config) throws ServletException { @Override public void destroy() { } + + public static TemporalAmount convertToTemporalAmount(@Nullable String periodParam, TemporalAmount defaultPeriod) { + TemporalAmount period = defaultPeriod; + String convertedPeriod = convertPeriodToISO8601(periodParam); + if (convertedPeriod != null) { + boolean failed = false; + try { + period = Period.parse(convertedPeriod); + } catch (DateTimeParseException e) { + failed = true; + } + if (failed) { + try { + period = Duration.parse(convertedPeriod); + } catch (DateTimeParseException e) { + // Ignored + } + } + } + return period; + } + + private static @Nullable String convertPeriodToISO8601(@Nullable String period) { + if (period == null || period.startsWith("P") || !(period.endsWith("h") || period.endsWith("D") + || period.endsWith("W") || period.endsWith("M") || period.endsWith("Y"))) { + return period; + } + String newPeriod = period.length() == 1 ? "1" + period : period; + if (newPeriod.endsWith("h")) { + newPeriod = "T" + newPeriod.replace("h", "H"); + } + return "P" + newPeriod; + } } diff --git a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartTheme.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartTheme.java index 23740561fca..5272ee9112d 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartTheme.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartTheme.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeBlack.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeBlack.java index e7cddf37d9a..e11dfb68e1e 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeBlack.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeBlack.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeBlackTransparent.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeBlackTransparent.java index ab460682c81..34c14c08901 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeBlackTransparent.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeBlackTransparent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeBright.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeBright.java index 68a61740cbd..de02042e10d 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeBright.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeBright.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeBrightTransparent.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeBrightTransparent.java index 32bf345fa66..31aaa7b1068 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeBrightTransparent.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeBrightTransparent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeDark.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeDark.java index 9cb6a33e0c1..c8282527da3 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeDark.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeDark.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeDarkTransparent.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeDarkTransparent.java index 78cdb768d76..bdb6f4faca9 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeDarkTransparent.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeDarkTransparent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeWhite.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeWhite.java index a7e2e92a65b..9622fd3d091 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeWhite.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeWhite.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeWhiteTransparent.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeWhiteTransparent.java index e920657bc60..994ff22ee5c 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeWhiteTransparent.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/ChartThemeWhiteTransparent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/DefaultChartProvider.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/DefaultChartProvider.java index 1c8304a336e..98d97287c43 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/DefaultChartProvider.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/chart/defaultchartprovider/DefaultChartProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -153,7 +153,7 @@ public BufferedImage createChart(@Nullable String serviceId, @Nullable String th QueryablePersistenceService persistenceService = (service instanceof QueryablePersistenceService qps) ? qps : (QueryablePersistenceService) persistenceServiceRegistry.getAll() // .stream() // - .filter(it -> it instanceof QueryablePersistenceService) // + .filter(QueryablePersistenceService.class::isInstance) // .findFirst() // .orElseThrow(() -> new IllegalArgumentException("No Persistence service found.")); @@ -300,7 +300,7 @@ private double convertData(State state) { } else if (state instanceof OpenClosedType) { return state == OpenClosedType.CLOSED ? 0 : 1; } else { - logger.debug("Unsupported item type in chart: {}", state.getClass().toString()); + logger.debug("Unsupported item type in chart: {}", state.getClass()); return 0; } } diff --git a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/ManagedUIComponentProvider.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/ManagedUIComponentProvider.java index ce260d1453c..b971440c3c7 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/ManagedUIComponentProvider.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/ManagedUIComponentProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentRegistryFactoryImpl.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentRegistryFactoryImpl.java index 8796887b18f..952ce3b1b06 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentRegistryFactoryImpl.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentRegistryFactoryImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentRegistryImpl.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentRegistryImpl.java index 725775fb3c5..2632928ad1c 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentRegistryImpl.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentRegistryImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to 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.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentSitemapProvider.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentSitemapProvider.java index 31036ae544f..f07ef8cdedf 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentSitemapProvider.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentSitemapProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -20,6 +20,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; +import java.util.function.Predicate; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -239,6 +240,8 @@ protected Sitemap buildSitemap(RootUIComponent rootComponent) { setWidgetPropertyFromComponentConfig(widget, component, "step", SitemapPackage.SLIDER__STEP); setWidgetPropertyFromComponentConfig(widget, component, "switchEnabled", SitemapPackage.SLIDER__SWITCH_ENABLED); + setWidgetPropertyFromComponentConfig(widget, component, "releaseOnly", + SitemapPackage.SLIDER__RELEASE_ONLY); setWidgetPropertyFromComponentConfig(widget, component, "sendFrequency", SitemapPackage.SLIDER__FREQUENCY); break; @@ -269,7 +272,6 @@ protected Sitemap buildSitemap(RootUIComponent rootComponent) { ButtongridImpl buttongridWidget = (ButtongridImpl) SitemapFactory.eINSTANCE.createButtongrid(); addWidgetButtons(buttongridWidget.getButtons(), component); widget = buttongridWidget; - setWidgetPropertyFromComponentConfig(widget, component, "columns", SitemapPackage.BUTTONGRID__COLUMNS); break; case "Default": DefaultImpl defaultWidget = (DefaultImpl) SitemapFactory.eINSTANCE.createDefault(); @@ -321,7 +323,7 @@ private void setWidgetPropertyFromComponentConfig(Widget widget, @Nullable UICom Object normalizedValue = ConfigUtil.normalizeType(value); if (widgetImpl.eGet(feature, false, false) instanceof Integer) { normalizedValue = (normalizedValue instanceof BigDecimal bd) ? bd.intValue() - : Integer.valueOf(normalizedValue.toString()); + : Integer.parseInt(normalizedValue.toString()); } else if (widgetImpl.eGet(feature, false, false) instanceof Boolean && !(normalizedValue instanceof Boolean)) { normalizedValue = Boolean.valueOf(normalizedValue.toString()); @@ -338,7 +340,7 @@ private void setWidgetIconPropertyFromComponentConfig(Widget widget, @Nullable U return; } Object staticIcon = component.getConfig().get("staticIcon"); - if (staticIcon != null && Boolean.valueOf(ConfigUtil.normalizeType(staticIcon).toString())) { + if (staticIcon != null && Boolean.parseBoolean(ConfigUtil.normalizeType(staticIcon).toString())) { setWidgetPropertyFromComponentConfig(widget, component, "icon", SitemapPackage.WIDGET__STATIC_ICON); return; } @@ -377,14 +379,16 @@ private void addWidgetButtons(EList