Skip to content

Commit

Permalink
Rebased + code review n°5
Browse files Browse the repository at this point in the history
Restoring pom.xml + my binding

Signed-off-by: Gaël L'hopital <gael@lhopital.org>
  • Loading branch information
clinique committed May 26, 2024
1 parent e54d2b6 commit 9d7cb3a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions bundles/org.openhab.binding.ephemeris/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,23 @@ public CustomHandler(Thing thing, EphemerisManager ephemerisManager, ZoneId zone

@Override
public void initialize() {
FileConfiguration config = getConfigAs(FileConfiguration.class);
File file = new File(BINDING_DATA_PATH, config.fileName);
if (file.exists()) {
definitionFile = Optional.of(file);
super.initialize();
} else {
String fileName = getConfigAs(FileConfiguration.class).fileName;

if (fileName.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"'fileName' can not be blank or empty");
return;
}

File file = new File(BINDING_DATA_PATH, fileName);
if (!file.exists()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Missing file: %s".formatted(file.getAbsolutePath()));
return;
}

definitionFile = Optional.of(file);
super.initialize();
}

@Override
Expand Down

0 comments on commit 9d7cb3a

Please sign in to comment.