From e7acff9f54459bb9a76424469d6041568a92909b Mon Sep 17 00:00:00 2001 From: bwssystems Date: Sat, 19 Nov 2016 14:12:32 -0600 Subject: [PATCH] Fixed MQTT initialization error with maven build inclusion. Added URI encoder to handle URI calls with URL characters. Fixes #250 Fixes #251 Fixes #252 --- pom.xml | 8 +++++++- .../com/bwssystems/HABridge/hue/HueMulator.java | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 620f57f..9838e2b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.bwssystems.HABridge ha-bridge - 3.5.0 + 3.5.1 jar HA Bridge @@ -192,6 +192,12 @@ ** + + org.eclipse.paho:org.eclipse.paho.client.mqttv3 + + ** + + 0) { @@ -1132,17 +1135,22 @@ public class HueMulator implements HueErrorStringSet { if(body != null && body.length() > 0) requestBody = new StringEntity(body, parsedContentType); } - + try { + theURI = new URI(url); + } catch (URISyntaxException e1) { + log.warn("Error creating URI http request: " + url + " with message: " + e1.getMessage()); + return null; + } try { if(HttpGet.METHOD_NAME.equalsIgnoreCase(httpVerb) || httpVerb == null) { - request = new HttpGet(url); + request = new HttpGet(theURI); }else if(HttpPost.METHOD_NAME.equalsIgnoreCase(httpVerb)){ - HttpPost postRequest = new HttpPost(url); + HttpPost postRequest = new HttpPost(theURI); if(requestBody != null) postRequest.setEntity(requestBody); request = postRequest; }else if(HttpPut.METHOD_NAME.equalsIgnoreCase(httpVerb)){ - HttpPut putRequest = new HttpPut(url); + HttpPut putRequest = new HttpPut(theURI); if(requestBody != null) putRequest.setEntity(requestBody); request = putRequest;