14
14
import com .bwssystems .harmony .RunActivity ;
15
15
import com .bwssystems .nest .controller .Nest ;
16
16
import com .bwssystems .util .JsonTransformer ;
17
- import com .bwssystems .util .TextStringFormatter ;
18
17
import com .fasterxml .jackson .databind .DeserializationFeature ;
19
18
import com .fasterxml .jackson .databind .ObjectMapper ;
20
19
import com .google .gson .Gson ;
@@ -565,23 +564,27 @@ protected String replaceIntensityValue(String request, int intensity){
565
564
566
565
567
566
// This function executes the url from the device repository against the vera
568
- protected boolean doHttpRequest (String anUrl , String httpVerb , String contentType , String body ) {
567
+ protected boolean doHttpRequest (String url , String httpVerb , String contentType , String body ) {
569
568
HttpUriRequest request = null ;
570
- String url = TextStringFormatter .forURL (anUrl );
571
- if (HttpGet .METHOD_NAME .equalsIgnoreCase (httpVerb ) || httpVerb == null ) {
572
- request = new HttpGet (url );
573
- }else if (HttpPost .METHOD_NAME .equalsIgnoreCase (httpVerb )){
574
- HttpPost postRequest = new HttpPost (url );
575
- ContentType parsedContentType = ContentType .parse (contentType );
576
- StringEntity requestBody = new StringEntity (body , parsedContentType );
577
- postRequest .setEntity (requestBody );
578
- request = postRequest ;
579
- }else if (HttpPut .METHOD_NAME .equalsIgnoreCase (httpVerb )){
580
- HttpPut putRequest = new HttpPut (url );
581
- ContentType parsedContentType = ContentType .parse (contentType );
582
- StringEntity requestBody = new StringEntity (body , parsedContentType );
583
- putRequest .setEntity (requestBody );
584
- request = putRequest ;
569
+ try {
570
+ if (HttpGet .METHOD_NAME .equalsIgnoreCase (httpVerb ) || httpVerb == null ) {
571
+ request = new HttpGet (url );
572
+ }else if (HttpPost .METHOD_NAME .equalsIgnoreCase (httpVerb )){
573
+ HttpPost postRequest = new HttpPost (url );
574
+ ContentType parsedContentType = ContentType .parse (contentType );
575
+ StringEntity requestBody = new StringEntity (body , parsedContentType );
576
+ postRequest .setEntity (requestBody );
577
+ request = postRequest ;
578
+ }else if (HttpPut .METHOD_NAME .equalsIgnoreCase (httpVerb )){
579
+ HttpPut putRequest = new HttpPut (url );
580
+ ContentType parsedContentType = ContentType .parse (contentType );
581
+ StringEntity requestBody = new StringEntity (body , parsedContentType );
582
+ putRequest .setEntity (requestBody );
583
+ request = putRequest ;
584
+ }
585
+ } catch (IllegalArgumentException e ) {
586
+ log .warn ("Error calling out to HA gateway: IllegalArgumentException in log" , e );
587
+ return false ;
585
588
}
586
589
log .debug ("Making outbound call in doHttpRequest: " + request );
587
590
try {
@@ -592,7 +595,7 @@ protected boolean doHttpRequest(String anUrl, String httpVerb, String contentTyp
592
595
return true ;
593
596
}
594
597
} catch (IOException e ) {
595
- log .warn ("Error calling out to HA gateway" , e );
598
+ log .warn ("Error calling out to HA gateway: IOException in log " , e );
596
599
}
597
600
return false ;
598
601
}
0 commit comments