...
This commit is contained in:
@@ -20,6 +20,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.api.ContentResponse;
|
||||
import org.eclipse.jetty.client.api.Request;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.openhab.binding.mediolaaiogateway.internal.config.MediolaAioBridgeConfig;
|
||||
import org.openhab.binding.mediolaaiogateway.internal.discovery.MediolaAioDeviceDiscoveryService;
|
||||
@@ -100,24 +101,30 @@ public class MediolaAioGatewayBridgeHandler extends BaseBridgeHandler {
|
||||
synchronized (this) {
|
||||
try {
|
||||
response = request.send();
|
||||
|
||||
if(!HttpStatus.isSuccess(response.getStatus())) {
|
||||
throw new MediolaAioCommunicationError("invalid http result code");
|
||||
}
|
||||
content = response.getContent();
|
||||
} catch (InterruptedException | TimeoutException | ExecutionException e) {
|
||||
throw new MediolaAioCommunicationError("communication error", e);
|
||||
}
|
||||
}
|
||||
|
||||
JsonObject convertedObject = new Gson().fromJson(new String(content), JsonObject.class);
|
||||
if (!convertedObject.has("XC_SUC")) {
|
||||
if (convertedObject.has("XC_ERR")) {
|
||||
throw new MediolaAioCommandError(convertedObject.get("XC_ERR").getAsString());
|
||||
} else {
|
||||
throw new MediolaAioCommandError("unknown reason.");
|
||||
try {
|
||||
JsonObject convertedObject = new Gson().fromJson(new String(content), JsonObject.class);
|
||||
if (!convertedObject.has("XC_SUC")) {
|
||||
if (convertedObject.has("XC_ERR")) {
|
||||
throw new MediolaAioCommandError(convertedObject.get("XC_ERR").getAsString());
|
||||
} else {
|
||||
throw new MediolaAioCommandError("unknown reason.");
|
||||
}
|
||||
}
|
||||
|
||||
return convertedObject.get("XC_SUC");
|
||||
} catch (Exception e) {
|
||||
throw new MediolaAioCommandError("json decode of response failed.");
|
||||
}
|
||||
|
||||
return convertedObject.get("XC_SUC");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user