import org.openhab.binding.roku.internal.dto.TvChannel;
import org.openhab.binding.roku.internal.dto.TvChannels;
import org.openhab.binding.roku.internal.dto.TvChannels.Channel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Methods for accessing the HTTP interface of the Roku
public class RokuCommunicator {
private static final int REQUEST_TIMEOUT = 5000;
+ private final Logger logger = LoggerFactory.getLogger(RokuCommunicator.class);
private final HttpClient httpClient;
private final String urlKeyPress;
JAXBContext ctx = JAXBUtils.JAXBCONTEXT_DEVICE_INFO;
if (ctx != null) {
final String response = getCommand(urlQryDevice);
+ logger.trace("Called {}, got response: {}", urlQryDevice, response);
+
Unmarshaller unmarshaller = ctx.createUnmarshaller();
if (unmarshaller != null) {
XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(response));
JAXBContext ctx = JAXBUtils.JAXBCONTEXT_ACTIVE_APP;
if (ctx != null) {
final String response = getCommand(urlQryActiveApp);
+ logger.trace("Called {}, got response: {}", urlQryActiveApp, response);
+
Unmarshaller unmarshaller = ctx.createUnmarshaller();
if (unmarshaller != null) {
XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(response));
JAXBContext ctx = JAXBUtils.JAXBCONTEXT_APPS;
if (ctx != null) {
final String response = getCommand(urlQryApps);
+ logger.trace("Called {}, got response: {}", urlQryApps, response);
+
Unmarshaller unmarshaller = ctx.createUnmarshaller();
if (unmarshaller != null) {
XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(response));
JAXBContext ctx = JAXBUtils.JAXBCONTEXT_PLAYER;
if (ctx != null) {
final String response = getCommand(urlQryPlayer);
+ logger.trace("Called {}, got response: {}", urlQryPlayer, response);
+
Unmarshaller unmarshaller = ctx.createUnmarshaller();
if (unmarshaller != null) {
XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(response));
JAXBContext ctx = JAXBUtils.JAXBCONTEXT_TVCHANNEL;
if (ctx != null) {
final String response = getCommand(urlQryActiveTvChannel);
+ logger.trace("Called {}, got response: {}", urlQryActiveTvChannel, response);
+
Unmarshaller unmarshaller = ctx.createUnmarshaller();
if (unmarshaller != null) {
XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(response));
JAXBContext ctx = JAXBUtils.JAXBCONTEXT_TVCHANNELS;
if (ctx != null) {
final String response = getCommand(urlQryTvChannels);
+ logger.trace("Called {}, got response: {}", urlQryTvChannels, response);
+
Unmarshaller unmarshaller = ctx.createUnmarshaller();
if (unmarshaller != null) {
XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(response));
*/
private void postCommand(String url) throws RokuHttpException {
try {
+ logger.trace("Sending POST command: {}", url);
httpClient.POST(url).method(HttpMethod.POST).timeout(REQUEST_TIMEOUT, TimeUnit.MILLISECONDS).send();
} catch (TimeoutException | ExecutionException e) {
throw new RokuHttpException("Error executing POST command, URL: " + url, e);