Prevent a timeout from the server from stopping the binding (#11555)
Signed-off-by: EvilPingu <ckittel@gmx.de>
This commit is contained in:
parent
afdbd09eb3
commit
2c7acbcc21
|
@ -19,6 +19,8 @@ import org.openhab.binding.ojelectronics.internal.ThermostatHandler;
|
||||||
import org.openhab.binding.ojelectronics.internal.models.Thermostat;
|
import org.openhab.binding.ojelectronics.internal.models.Thermostat;
|
||||||
import org.openhab.binding.ojelectronics.internal.models.groups.GroupContent;
|
import org.openhab.binding.ojelectronics.internal.models.groups.GroupContent;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refreshes values of {@link ThermostatHandler}
|
* Refreshes values of {@link ThermostatHandler}
|
||||||
|
@ -29,6 +31,7 @@ import org.openhab.core.thing.Thing;
|
||||||
public class RefreshGroupContentService {
|
public class RefreshGroupContentService {
|
||||||
|
|
||||||
private final List<GroupContent> groupContentList;
|
private final List<GroupContent> groupContentList;
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(RefreshGroupContentService.class);
|
||||||
private List<Thing> things;
|
private List<Thing> things;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,6 +43,9 @@ public class RefreshGroupContentService {
|
||||||
public RefreshGroupContentService(List<GroupContent> groupContents, List<Thing> things) {
|
public RefreshGroupContentService(List<GroupContent> groupContents, List<Thing> things) {
|
||||||
this.groupContentList = groupContents;
|
this.groupContentList = groupContents;
|
||||||
this.things = things;
|
this.things = things;
|
||||||
|
if (this.things.isEmpty()) {
|
||||||
|
logger.warn("Bridge contains no thermostats.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -115,14 +115,21 @@ public final class RefreshService implements AutoCloseable {
|
||||||
if (!destroyed) {
|
if (!destroyed) {
|
||||||
if (result == null || result.isFailed()) {
|
if (result == null || result.isFailed()) {
|
||||||
handleConnectionLost();
|
handleConnectionLost();
|
||||||
} else if (result.getResponse().getStatus() == HttpStatus.FORBIDDEN_403) {
|
|
||||||
if (unauthorized != null) {
|
|
||||||
unauthorized.run();
|
|
||||||
}
|
|
||||||
} else if (result.getResponse().getStatus() == HttpStatus.FORBIDDEN_403) {
|
|
||||||
handleConnectionLost();
|
|
||||||
} else {
|
} else {
|
||||||
handleRefreshDone(getContentAsString());
|
int status = result.getResponse().getStatus();
|
||||||
|
logger.trace("HTTP-Status {}", status);
|
||||||
|
if (status == HttpStatus.FORBIDDEN_403) {
|
||||||
|
if (unauthorized != null) {
|
||||||
|
unauthorized.run();
|
||||||
|
} else {
|
||||||
|
handleConnectionLost();
|
||||||
|
}
|
||||||
|
} else if (status == HttpStatus.OK_200) {
|
||||||
|
handleRefreshDone(getContentAsString());
|
||||||
|
} else {
|
||||||
|
logger.warn("unsupported HTTP-Status {}", status);
|
||||||
|
handleConnectionLost();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue