diff --git a/pom.xml b/pom.xml
index e090479..2a1e20c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
com.bwssystems.HABridge
ha-bridge
- 1.4.2a
+ 1.4.3
jar
HA Bridge
diff --git a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
index 6859eff..e3af6be 100644
--- a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
+++ b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
@@ -14,7 +14,6 @@ import com.bwssystems.harmony.HarmonyHome;
import com.bwssystems.harmony.RunActivity;
import com.bwssystems.nest.controller.Nest;
import com.bwssystems.util.JsonTransformer;
-import com.bwssystems.util.TextStringFormatter;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
@@ -565,23 +564,27 @@ public class HueMulator {
// This function executes the url from the device repository against the vera
- protected boolean doHttpRequest(String anUrl, String httpVerb, String contentType, String body) {
+ protected boolean doHttpRequest(String url, String httpVerb, String contentType, String body) {
HttpUriRequest request = null;
- String url = TextStringFormatter.forURL(anUrl);
- if(HttpGet.METHOD_NAME.equalsIgnoreCase(httpVerb) || httpVerb == null) {
- request = new HttpGet(url);
- }else if(HttpPost.METHOD_NAME.equalsIgnoreCase(httpVerb)){
- HttpPost postRequest = new HttpPost(url);
- ContentType parsedContentType = ContentType.parse(contentType);
- StringEntity requestBody = new StringEntity(body, parsedContentType);
- postRequest.setEntity(requestBody);
- request = postRequest;
- }else if(HttpPut.METHOD_NAME.equalsIgnoreCase(httpVerb)){
- HttpPut putRequest = new HttpPut(url);
- ContentType parsedContentType = ContentType.parse(contentType);
- StringEntity requestBody = new StringEntity(body, parsedContentType);
- putRequest.setEntity(requestBody);
- request = putRequest;
+ try {
+ if(HttpGet.METHOD_NAME.equalsIgnoreCase(httpVerb) || httpVerb == null) {
+ request = new HttpGet(url);
+ }else if(HttpPost.METHOD_NAME.equalsIgnoreCase(httpVerb)){
+ HttpPost postRequest = new HttpPost(url);
+ ContentType parsedContentType = ContentType.parse(contentType);
+ StringEntity requestBody = new StringEntity(body, parsedContentType);
+ postRequest.setEntity(requestBody);
+ request = postRequest;
+ }else if(HttpPut.METHOD_NAME.equalsIgnoreCase(httpVerb)){
+ HttpPut putRequest = new HttpPut(url);
+ ContentType parsedContentType = ContentType.parse(contentType);
+ StringEntity requestBody = new StringEntity(body, parsedContentType);
+ putRequest.setEntity(requestBody);
+ request = putRequest;
+ }
+ } catch(IllegalArgumentException e) {
+ log.warn("Error calling out to HA gateway: IllegalArgumentException in log", e);
+ return false;
}
log.debug("Making outbound call in doHttpRequest: " + request);
try {
@@ -592,7 +595,7 @@ public class HueMulator {
return true;
}
} catch (IOException e) {
- log.warn("Error calling out to HA gateway", e);
+ log.warn("Error calling out to HA gateway: IOException in log", e);
}
return false;
}
diff --git a/src/main/java/com/bwssystems/util/TextStringFormatter.java b/src/main/java/com/bwssystems/util/TextStringFormatter.java
index fe4160a..9566401 100644
--- a/src/main/java/com/bwssystems/util/TextStringFormatter.java
+++ b/src/main/java/com/bwssystems/util/TextStringFormatter.java
@@ -218,6 +218,9 @@ public final class TextStringFormatter {
return aURL.replace("&", "&");
}
+ public static String forQuerySpace(String aURL) {
+ return aURL.replace(" ", "\u0020");
+ }
/**
* Synonym for URLEncoder.encode(String, "UTF-8").
*