[icalendar] Reload calendar file asynchronously (#9227)
* Reload calendar file asynchronously * Incorporated comments from review Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
parent
3eda5ebbc9
commit
1a6f5b5158
|
@ -120,8 +120,6 @@ public class ICalendarHandler extends BaseBridgeHandler implements CalendarUpdat
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
updateStatus(ThingStatus.UNKNOWN);
|
|
||||||
|
|
||||||
final ICalendarConfiguration currentConfiguration = getConfigAs(ICalendarConfiguration.class);
|
final ICalendarConfiguration currentConfiguration = getConfigAs(ICalendarConfiguration.class);
|
||||||
configuration = currentConfiguration;
|
configuration = currentConfiguration;
|
||||||
|
|
||||||
|
@ -154,14 +152,17 @@ public class ICalendarHandler extends BaseBridgeHandler implements CalendarUpdat
|
||||||
}
|
}
|
||||||
final long refreshTime = refreshTimeBD.longValue();
|
final long refreshTime = refreshTimeBD.longValue();
|
||||||
if (calendarFile.isFile()) {
|
if (calendarFile.isFile()) {
|
||||||
if (reloadCalendar()) {
|
updateStatus(ThingStatus.ONLINE);
|
||||||
updateStatus(ThingStatus.ONLINE);
|
|
||||||
updateStates();
|
scheduler.submit(() -> {
|
||||||
rescheduleCalendarStateUpdate();
|
// reload calendar file asynchronously
|
||||||
} else {
|
if (reloadCalendar()) {
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
|
updateStates();
|
||||||
"The calendar seems to be configured correctly, but the local copy of calendar could not be loaded.");
|
} else {
|
||||||
}
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
|
||||||
|
"The calendar seems to be configured correctly, but the local copy of calendar could not be loaded.");
|
||||||
|
}
|
||||||
|
});
|
||||||
pullJobFuture = scheduler.scheduleWithFixedDelay(regularPull, refreshTime, refreshTime,
|
pullJobFuture = scheduler.scheduleWithFixedDelay(regularPull, refreshTime, refreshTime,
|
||||||
TimeUnit.MINUTES);
|
TimeUnit.MINUTES);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue