Skip to content
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tools/upgradetool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<properties>
<jackson.annotations.version>2.21</jackson.annotations.version>
<jackson.version>2.21.0</jackson.version>
<maven.version>3.9.12</maven.version>
</properties>

<dependencies>
Expand All @@ -43,6 +44,11 @@
<artifactId>org.openhab.core.persistence</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.core.bundles</groupId>
<artifactId>org.openhab.core.semantics</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.core.bundles</groupId>
<artifactId>org.openhab.core.storage.json</artifactId>
Expand Down Expand Up @@ -92,6 +98,11 @@
<version>${jackson.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ public interface Upgrader {

String getDescription();

default @Nullable String getTargetVersion() {
return null;
}

/**
* Executes the upgrade process.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* installed, and if Home Assistant things exist, and if so installs the
* Home Assistant addon.
*
* @since 5.1.0
*
* @author Cody Cutrer - Initial contribution
*/
@NonNullByDefault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* installed, and if Home Assistant things exist, and if so installs the
* Home Assistant addon.
*
* @since 5.1.0
*
* @author Cody Cutrer - Initial contribution
*/
@NonNullByDefault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ public boolean execute(@Nullable Path userdataPath, @Nullable Path confPath) {
return false;
}

userdataPath = userdataPath.resolve("jsondb");
Path dataPath = userdataPath.resolve("jsondb");
boolean noLink;

Path itemJsonDatabasePath = userdataPath.resolve("org.openhab.core.items.Item.json");
Path metadataJsonDatabasePath = userdataPath.resolve("org.openhab.core.items.Metadata.json");
Path linkJsonDatabasePath = userdataPath.resolve("org.openhab.core.thing.link.ItemChannelLink.json");
Path thingJsonDatabasePath = userdataPath.resolve("org.openhab.core.thing.Thing.json");
Path itemJsonDatabasePath = dataPath.resolve("org.openhab.core.items.Item.json");
Path metadataJsonDatabasePath = dataPath.resolve("org.openhab.core.items.Metadata.json");
Path linkJsonDatabasePath = dataPath.resolve("org.openhab.core.thing.link.ItemChannelLink.json");
Path thingJsonDatabasePath = dataPath.resolve("org.openhab.core.thing.Thing.json");
logger.info("Copying item unit from state description to metadata in database '{}'", itemJsonDatabasePath);

if (!Files.isReadable(itemJsonDatabasePath)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
/**
* The {@link JSProfileUpgrader} upgrades JS Profile configurations
*
* @since 4.0.0
*
* @author Jan N. Klug - Initial contribution
* @author Jimmy Tanagra - Refactored into a separate class
*/
Expand All @@ -54,9 +56,9 @@ public boolean execute(@Nullable Path userdataPath, @Nullable Path confPath) {
return false;
}

userdataPath = userdataPath.resolve("jsondb");
Path dataPath = userdataPath.resolve("jsondb");

Path linkJsonDatabasePath = userdataPath.resolve("org.openhab.core.thing.link.ItemChannelLink.json");
Path linkJsonDatabasePath = dataPath.resolve("org.openhab.core.thing.link.ItemChannelLink.json");
logger.info("Upgrading JS profile configuration in database '{}'", linkJsonDatabasePath);

if (!Files.isWritable(linkJsonDatabasePath)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
* configuration that has no strategy defined.
* See <a href="https://github.com/openhab/openhab-core/pull/4682">openhab/openhab-core#4682</a>.
*
* @since 5.1.0
*
* @author Mark Herwege - Initial Contribution
*/
@NonNullByDefault
Expand Down Expand Up @@ -123,28 +125,32 @@ public boolean execute(@Nullable Path userdataPath, @Nullable Path confPath) {

// Update existing managed configurations
persistenceStorageKeys.forEach(serviceId -> {
PersistenceServiceConfigurationDTO serviceConfigDTO = Objects
.requireNonNull(persistenceStorage.get(serviceId));
Collection<String> defaults = serviceConfigDTO.defaults;
if (defaults != null) {
Collection<PersistenceItemConfigurationDTO> configs = serviceConfigDTO.configs;
configs.forEach(config -> {
Collection<String> strategies = config.strategies;
if (strategies.isEmpty()) {
config.strategies = defaults;
}
});
serviceConfigDTO.defaults = null;

persistenceStorage.put(serviceId, serviceConfigDTO);
logger.info("{}: updated strategy configurations and removed default strategies", serviceId);
}
updateConfig(persistenceStorage, serviceId);
});

persistenceStorage.flush();
return true;
}

@SuppressWarnings("deprecation")
private void updateConfig(JsonStorage<PersistenceServiceConfigurationDTO> persistenceStorage, String serviceId) {
PersistenceServiceConfigurationDTO serviceConfigDTO = Objects.requireNonNull(persistenceStorage.get(serviceId));
Collection<String> defaults = serviceConfigDTO.defaults;
if (defaults != null) {
Collection<PersistenceItemConfigurationDTO> configs = serviceConfigDTO.configs;
configs.forEach(config -> {
Collection<String> strategies = config.strategies;
if (strategies.isEmpty()) {
config.strategies = defaults;
}
});
serviceConfigDTO.defaults = null;

persistenceStorage.put(serviceId, serviceConfigDTO);
logger.info("{}: updated strategy configurations and removed default strategies", serviceId);
}
}

private List<String> installedPersistenceAddons(Path userdataPath) throws IOException {
Path addonsConfigPath = userdataPath.resolve("config/org/openhab/addons.config");
if (Files.notExists(addonsConfigPath)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
* {@code commandFromItemScript} and {@code stateFromItemScript}.
* See <a href="https://github.com/openhab/openhab-core/pull/4058">openhab/openhab-core#4058</a>.
*
* @since 4.2.0
*
* @author Florian Hotze - Initial contribution
* @author Jimmy Tanagra - Refactored into a separate class
*/
Expand Down
Loading
Loading