From 14bca8c1abf430bb9d57d168dabb38d1ec6923af Mon Sep 17 00:00:00 2001 From: Ludovic Roland Date: Tue, 23 Aug 2016 09:28:32 +0200 Subject: [PATCH 1/8] Restore the modifications on the SmartAppCompatActivity class --- .../support/v7/app/SmartAppCompatActivity.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/droid4me/src/com/smartnsoft/droid4me/support/v7/app/SmartAppCompatActivity.java b/droid4me/src/com/smartnsoft/droid4me/support/v7/app/SmartAppCompatActivity.java index 043af9dd..71d5efc5 100644 --- a/droid4me/src/com/smartnsoft/droid4me/support/v7/app/SmartAppCompatActivity.java +++ b/droid4me/src/com/smartnsoft/droid4me/support/v7/app/SmartAppCompatActivity.java @@ -53,11 +53,11 @@ public LayoutInflater getLayoutInflater() @Override public Object getSystemService(String name) { - // if (Context.LAYOUT_INFLATER_SERVICE.equals(name) == true && getWindow() != null) - // { - // return droid4mizer.getSystemService(name, getWindow().getLayoutInflater()); - // } - // else + if (Context.LAYOUT_INFLATER_SERVICE.equals(name) == true && getWindow() != null) + { + return droid4mizer.getSystemService(name, getWindow().getLayoutInflater()); + } + else { return droid4mizer.getSystemService(name, super.getSystemService(name)); } From 1b193561fab75a1a8979587ef427bb2750166286 Mon Sep 17 00:00:00 2001 From: Ludovic Roland Date: Tue, 25 Oct 2016 09:36:15 +0200 Subject: [PATCH 2/8] RED-149 #time 15m The HttpResponse class has not the request status code has an attribut --- droid4me/VERSION.txt | 2 +- droid4me/pom.xml | 2 +- .../droid4me/ws/URLConnectionWebServiceCaller.java | 3 ++- .../src/com/smartnsoft/droid4me/ws/WebServiceCaller.java | 5 ++++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/droid4me/VERSION.txt b/droid4me/VERSION.txt index 48a6b508..f3c55004 100755 --- a/droid4me/VERSION.txt +++ b/droid4me/VERSION.txt @@ -1 +1 @@ -2.4.7 \ No newline at end of file +2.4.8.003-SNAPSHOT \ No newline at end of file diff --git a/droid4me/pom.xml b/droid4me/pom.xml index 6f175df7..49f4cfe5 100644 --- a/droid4me/pom.xml +++ b/droid4me/pom.xml @@ -10,7 +10,7 @@ com.smartnsoft droid4me droid4me - 2.4.7 + 2.4.8.003-SNAPSHOT jar droid4me is a framework library dedicated to the development of Android applications. https://github.com/smartnsoft/droid4me diff --git a/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java b/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java index 5566fc23..724bd660 100644 --- a/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java +++ b/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java @@ -130,9 +130,10 @@ public HttpResponse runRequest(String uri, CallType callType, Map> headerFields = httpURLConnection.getHeaderFields(); + final int statusCode = httpURLConnection.getResponseCode(); final InputStream inputStream = getContent(uri, callType, httpURLConnection); - return new HttpResponse(headerFields, inputStream); + return new HttpResponse(headerFields, statusCode, inputStream); } catch (CallException exception) { diff --git a/droid4me/src/com/smartnsoft/droid4me/ws/WebServiceCaller.java b/droid4me/src/com/smartnsoft/droid4me/ws/WebServiceCaller.java index e252fbca..884104ad 100644 --- a/droid4me/src/com/smartnsoft/droid4me/ws/WebServiceCaller.java +++ b/droid4me/src/com/smartnsoft/droid4me/ws/WebServiceCaller.java @@ -72,11 +72,14 @@ public static final class HttpResponse public final Map> headers; + public final int statusCode; + public final InputStream inputStream; - public HttpResponse(Map> headers, InputStream inputStream) + public HttpResponse(Map> headers, int statusCode, InputStream inputStream) { this.headers = headers; + this.statusCode = statusCode; this.inputStream = inputStream; } From 18a124be1b7ea8af88cb2787fc2348656c9c5076 Mon Sep 17 00:00:00 2001 From: Ludovic Roland Date: Fri, 28 Oct 2016 13:32:50 +0200 Subject: [PATCH 3/8] RED-149 #time 15m Fixed the missing logs in post request --- droid4me/VERSION.txt | 2 +- droid4me/pom.xml | 2 +- .../smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/droid4me/VERSION.txt b/droid4me/VERSION.txt index f3c55004..0698af45 100755 --- a/droid4me/VERSION.txt +++ b/droid4me/VERSION.txt @@ -1 +1 @@ -2.4.8.003-SNAPSHOT \ No newline at end of file +2.4.8.004-SNAPSHOT \ No newline at end of file diff --git a/droid4me/pom.xml b/droid4me/pom.xml index 49f4cfe5..fd40adf2 100644 --- a/droid4me/pom.xml +++ b/droid4me/pom.xml @@ -10,7 +10,7 @@ com.smartnsoft droid4me droid4me - 2.4.8.003-SNAPSHOT + 2.4.8.004-SNAPSHOT jar droid4me is a framework library dedicated to the development of Android applications. https://github.com/smartnsoft/droid4me diff --git a/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java b/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java index 724bd660..1960c0fd 100644 --- a/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java +++ b/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java @@ -417,6 +417,10 @@ private HttpURLConnection performHttpRequest(String uri, CallType callType, Map< logBuilder.append(" Content-Type: " + file.contentType); } } + else + { + logBuilder.append(transformPostParametersToDataString(paramaters)); + } } else if (paramaters != null && paramaters.size() > 0) { From 6c29679f382ed3750b9fdaf24b8a4788011481ac Mon Sep 17 00:00:00 2001 From: Willy Noel Date: Mon, 9 Jan 2017 17:13:23 +0100 Subject: [PATCH 4/8] RED-149 #time 15m Changes Multipart FileInputStream attributes to inputStream --- droid4me/VERSION.txt | 2 +- droid4me/pom.xml | 2 +- .../ws/URLConnectionWebServiceCaller.java | 20 +++++----------- .../droid4me/ws/WebServiceCaller.java | 23 +++++++------------ 4 files changed, 16 insertions(+), 31 deletions(-) diff --git a/droid4me/VERSION.txt b/droid4me/VERSION.txt index 0698af45..c72ae9a6 100755 --- a/droid4me/VERSION.txt +++ b/droid4me/VERSION.txt @@ -1 +1 @@ -2.4.8.004-SNAPSHOT \ No newline at end of file +2.4.8.005-SNAPSHOT \ No newline at end of file diff --git a/droid4me/pom.xml b/droid4me/pom.xml index fd40adf2..c57b19fb 100644 --- a/droid4me/pom.xml +++ b/droid4me/pom.xml @@ -10,7 +10,7 @@ com.smartnsoft droid4me droid4me - 2.4.8.004-SNAPSHOT + 2.4.8.005-SNAPSHOT jar droid4me is a framework library dedicated to the development of Android applications. https://github.com/smartnsoft/droid4me diff --git a/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java b/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java index 1960c0fd..9e184f1e 100644 --- a/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java +++ b/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java @@ -18,15 +18,10 @@ package com.smartnsoft.droid4me.ws; -import java.io.BufferedWriter; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; +import com.smartnsoft.droid4me.log.Logger; +import com.smartnsoft.droid4me.log.LoggerFactory; + +import java.io.*; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; @@ -35,9 +30,6 @@ import java.util.Map; import java.util.Map.Entry; -import com.smartnsoft.droid4me.log.Logger; -import com.smartnsoft.droid4me.log.LoggerFactory; - /** * * A basis class for making web service calls easier. *

@@ -493,12 +485,12 @@ else if (paramaters != null && paramaters.size() > 0) outputStream.writeBytes(URLConnectionWebServiceCaller.NEW_LINE + URLConnectionWebServiceCaller.NEW_LINE); outputStream.flush(); - if (file.fileInputStream != null) + if (file.inputStream != null) { int bytesRead; final byte[] dataBuffer = new byte[1024]; - while ((bytesRead = file.fileInputStream.read(dataBuffer)) != -1) + while ((bytesRead = file.inputStream.read(dataBuffer)) != -1) { outputStream.write(dataBuffer, 0, bytesRead); } diff --git a/droid4me/src/com/smartnsoft/droid4me/ws/WebServiceCaller.java b/droid4me/src/com/smartnsoft/droid4me/ws/WebServiceCaller.java index 884104ad..a0afaa49 100644 --- a/droid4me/src/com/smartnsoft/droid4me/ws/WebServiceCaller.java +++ b/droid4me/src/com/smartnsoft/droid4me/ws/WebServiceCaller.java @@ -18,23 +18,16 @@ package com.smartnsoft.droid4me.ws; -import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.StringWriter; -import java.io.UnsupportedEncodingException; +import com.smartnsoft.droid4me.log.Logger; +import com.smartnsoft.droid4me.log.LoggerFactory; +import org.json.JSONException; + +import java.io.*; import java.net.URLEncoder; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import com.smartnsoft.droid4me.log.Logger; -import com.smartnsoft.droid4me.log.LoggerFactory; - -import org.json.JSONException; - /** * A basis class for making web service calls easier. * @@ -55,14 +48,14 @@ public static final class MultipartFile public final String contentType; - public final FileInputStream fileInputStream; + public final InputStream inputStream; - public MultipartFile(String name, String fileName, String contentType, FileInputStream fileInputStream) + public MultipartFile(String name, String fileName, String contentType, InputStream inputStream) { this.name = name; this.fileName = fileName; this.contentType = contentType; - this.fileInputStream = fileInputStream; + this.inputStream = inputStream; } } From ae9a863a2d7a3f5aec262112906c7c37ecfa8c68 Mon Sep 17 00:00:00 2001 From: Ludovic Roland Date: Tue, 14 Feb 2017 09:05:42 +0100 Subject: [PATCH 5/8] RED-149 #time 30m Updated the pom with the URL of the new nexus + trying to deploy on it --- droid4me/VERSION.txt | 2 +- droid4me/pom.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/droid4me/VERSION.txt b/droid4me/VERSION.txt index c72ae9a6..3f6ab001 100755 --- a/droid4me/VERSION.txt +++ b/droid4me/VERSION.txt @@ -1 +1 @@ -2.4.8.005-SNAPSHOT \ No newline at end of file +2.4.8.006-SNAPSHOT \ No newline at end of file diff --git a/droid4me/pom.xml b/droid4me/pom.xml index c57b19fb..f419525a 100644 --- a/droid4me/pom.xml +++ b/droid4me/pom.xml @@ -10,7 +10,7 @@ com.smartnsoft droid4me droid4me - 2.4.8.005-SNAPSHOT + 2.4.8.006-SNAPSHOT jar droid4me is a framework library dedicated to the development of Android applications. https://github.com/smartnsoft/droid4me @@ -404,7 +404,7 @@ deployment Internal Releases SNAPSHOT - http://developer.smartnsoft.com:8081/nexus/content/repositories/snapshots/ + http://nexus2.smartnsoft.com/nexus/content/repository/snapshots/ From 7899ffa8511499b8226a5a88d62f8fbd27584d8d Mon Sep 17 00:00:00 2001 From: Ludovic Roland Date: Tue, 14 Feb 2017 17:49:56 +0100 Subject: [PATCH 6/8] RED-149 #time 30m Fixed the snapshot repository uri --- droid4me/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/droid4me/pom.xml b/droid4me/pom.xml index f419525a..bb75d75a 100644 --- a/droid4me/pom.xml +++ b/droid4me/pom.xml @@ -404,7 +404,7 @@ deployment Internal Releases SNAPSHOT - http://nexus2.smartnsoft.com/nexus/content/repository/snapshots/ + http://nexus2.smartnsoft.com/nexus/content/repositories/snapshots/ From 82e4aa8a6685c40d558fa7c0003142124d47d996 Mon Sep 17 00:00:00 2001 From: Ludovic Roland Date: Wed, 15 Feb 2017 11:26:17 +0100 Subject: [PATCH 7/8] RED-149 #time 30m Added the flag InstanceFollowRedirects to the UrlConnection in order to automatically follow the redirection --- droid4me/VERSION.txt | 2 +- droid4me/pom.xml | 2 +- .../ws/URLConnectionWebServiceCaller.java | 17 +++++++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/droid4me/VERSION.txt b/droid4me/VERSION.txt index 3f6ab001..3a9c5314 100755 --- a/droid4me/VERSION.txt +++ b/droid4me/VERSION.txt @@ -1 +1 @@ -2.4.8.006-SNAPSHOT \ No newline at end of file +2.4.8.007-SNAPSHOT \ No newline at end of file diff --git a/droid4me/pom.xml b/droid4me/pom.xml index bb75d75a..dd86fa03 100644 --- a/droid4me/pom.xml +++ b/droid4me/pom.xml @@ -10,7 +10,7 @@ com.smartnsoft droid4me droid4me - 2.4.8.006-SNAPSHOT + 2.4.8.007-SNAPSHOT jar droid4me is a framework library dedicated to the development of Android applications. https://github.com/smartnsoft/droid4me diff --git a/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java b/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java index 9e184f1e..13d26d5f 100644 --- a/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java +++ b/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java @@ -18,10 +18,15 @@ package com.smartnsoft.droid4me.ws; -import com.smartnsoft.droid4me.log.Logger; -import com.smartnsoft.droid4me.log.LoggerFactory; - -import java.io.*; +import java.io.BufferedWriter; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; @@ -30,6 +35,9 @@ import java.util.Map; import java.util.Map.Entry; +import com.smartnsoft.droid4me.log.Logger; +import com.smartnsoft.droid4me.log.LoggerFactory; + /** * * A basis class for making web service calls easier. *

@@ -350,6 +358,7 @@ private HttpURLConnection performHttpRequest(String uri, CallType callType, Map< } } + httpURLConnection.setInstanceFollowRedirects(true); httpURLConnection.setReadTimeout(getReadTimeout()); httpURLConnection.setConnectTimeout(getConnectTimeout()); httpURLConnection.setDoInput(true); From b05e799b9773f8b24d208491834fd038c7735e71 Mon Sep 17 00:00:00 2001 From: Ludovic Roland Date: Wed, 15 Feb 2017 12:04:34 +0100 Subject: [PATCH 8/8] RED-149 Rollback the URLConnectionWeServiceCaller + updated the version name to 2.4.8 --- droid4me/VERSION.txt | 2 +- droid4me/pom.xml | 2 +- .../ws/URLConnectionWebServiceCaller.java | 111 ++++++++++-------- 3 files changed, 65 insertions(+), 50 deletions(-) diff --git a/droid4me/VERSION.txt b/droid4me/VERSION.txt index 3a9c5314..752a79ef 100755 --- a/droid4me/VERSION.txt +++ b/droid4me/VERSION.txt @@ -1 +1 @@ -2.4.8.007-SNAPSHOT \ No newline at end of file +2.4.8 \ No newline at end of file diff --git a/droid4me/pom.xml b/droid4me/pom.xml index dd86fa03..5f6d6359 100644 --- a/droid4me/pom.xml +++ b/droid4me/pom.xml @@ -10,7 +10,7 @@ com.smartnsoft droid4me droid4me - 2.4.8.007-SNAPSHOT + 2.4.8 jar droid4me is a framework library dedicated to the development of Android applications. https://github.com/smartnsoft/droid4me diff --git a/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java b/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java index 13d26d5f..26c78c3f 100644 --- a/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java +++ b/droid4me/src/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java @@ -62,18 +62,14 @@ public abstract class URLConnectionWebServiceCaller extends WebServiceCaller { + protected final static Logger log = LoggerFactory.getInstance(URLConnectionWebServiceCaller.class); + private final static String BOUNDARY = "URLConnectionWebServiceCaller"; private final static String HYPHEN_HYPHEN = "--"; private final static String NEW_LINE = "\r\n"; - protected final static Logger log = LoggerFactory.getInstance(URLConnectionWebServiceCaller.class); - - protected abstract int getReadTimeout(); - - protected abstract int getConnectTimeout(); - /** * Equivalent to calling {@link #runRequest(String, CallType, Map, String)} with {@code callType} parameter set to * {@code CallType.Get} and {@code body} and {@code parameters} parameters set to {@code null}. @@ -152,6 +148,10 @@ public HttpResponse runRequest(String uri, CallType callType, Map20X. The default implementation logs the problem and throws an exception. * @@ -283,7 +283,8 @@ protected InputStream getContent(String uri, CallType callType, HttpURLConnectio { if (log.isWarnEnabled()) { - log.error("Could not close the input stream corresponding to the copy of the HTTP response content", exception); + log.error("Could not close the input stream corresponding to the copy of the HTTP response content", + exception); } } @@ -317,6 +318,13 @@ protected InputStream getContent(String uri, CallType callType, HttpURLConnectio return null; } + protected HttpURLConnection performHttpRequest(String uri, CallType callType, Map headers, + Map parameters, String body, List files) + throws IOException, CallException + { + return performHttpRequest(uri, callType, headers, parameters, body, files, 0); + } + /** * Is responsible for returning an HTTP client instance, used for actually running the HTTP requests. *

@@ -350,7 +358,8 @@ private HttpURLConnection performHttpRequest(String uri, CallType callType, Map< { if (files != null && files.size() > 0) { - httpURLConnection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + URLConnectionWebServiceCaller.BOUNDARY); + httpURLConnection.setRequestProperty("Content-Type", + "multipart/form-data; boundary=" + URLConnectionWebServiceCaller.BOUNDARY); } else { @@ -358,31 +367,30 @@ private HttpURLConnection performHttpRequest(String uri, CallType callType, Map< } } - httpURLConnection.setInstanceFollowRedirects(true); httpURLConnection.setReadTimeout(getReadTimeout()); httpURLConnection.setConnectTimeout(getConnectTimeout()); httpURLConnection.setDoInput(true); switch (callType.verb) { - default: - case Get: - httpURLConnection.setRequestMethod("GET"); - break; - case Head: - httpURLConnection.setRequestMethod("HEAD"); - break; - case Post: - httpURLConnection.setRequestMethod("POST"); - httpURLConnection.setDoOutput(true); - break; - case Put: - httpURLConnection.setRequestMethod("PUT"); - httpURLConnection.setDoOutput(true); - break; - case Delete: - httpURLConnection.setRequestMethod("DELETE"); - break; + default: + case Get: + httpURLConnection.setRequestMethod("GET"); + break; + case Head: + httpURLConnection.setRequestMethod("HEAD"); + break; + case Post: + httpURLConnection.setRequestMethod("POST"); + httpURLConnection.setDoOutput(true); + break; + case Put: + httpURLConnection.setRequestMethod("PUT"); + httpURLConnection.setDoOutput(true); + break; + case Delete: + httpURLConnection.setRequestMethod("DELETE"); + break; } if (headers != null && headers.size() > 0) @@ -405,7 +413,8 @@ private HttpURLConnection performHttpRequest(String uri, CallType callType, Map< { for (final Entry parameter : paramaters.entrySet()) { - logBuilder.append(" " + URLConnectionWebServiceCaller.HYPHEN_HYPHEN + URLConnectionWebServiceCaller.BOUNDARY); + logBuilder.append( + " " + URLConnectionWebServiceCaller.HYPHEN_HYPHEN + URLConnectionWebServiceCaller.BOUNDARY); logBuilder.append(" Content-Disposition: form-data; name=\"" + parameter.getKey() + "\""); logBuilder.append(" " + parameter.getValue()); } @@ -413,8 +422,10 @@ private HttpURLConnection performHttpRequest(String uri, CallType callType, Map< for (final MultipartFile file : files) { - logBuilder.append(" " + URLConnectionWebServiceCaller.HYPHEN_HYPHEN + URLConnectionWebServiceCaller.BOUNDARY); - logBuilder.append(" Content-Disposition: form-data; name=\"" + file.name + "\"; filename=\"" + file.fileName + "\""); + logBuilder.append( + " " + URLConnectionWebServiceCaller.HYPHEN_HYPHEN + URLConnectionWebServiceCaller.BOUNDARY); + logBuilder.append( + " Content-Disposition: form-data; name=\"" + file.name + "\"; filename=\"" + file.fileName + "\""); logBuilder.append(" Content-Type: " + file.contentType); } } @@ -435,7 +446,8 @@ else if (paramaters != null && paramaters.size() > 0) try { - curlSb.append("\n>> ").append("curl --request ").append(callType.toString().toUpperCase()).append(" \"").append(uri).append("\""); + curlSb.append("\n>> ").append("curl --request ").append(callType.toString().toUpperCase()).append( + " \"").append(uri).append("\""); if (logBuilder != null && "".equals(logBuilder.toString()) == false) { @@ -448,7 +460,8 @@ else if (paramaters != null && paramaters.size() > 0) { for (final String headerValue : header.getValue()) { - curlSb.append(" --header \"").append(header.getKey()).append(": ").append(headerValue.replace("\"", "\\\"")).append("\""); + curlSb.append(" --header \"").append(header.getKey()).append(": ").append( + headerValue.replace("\"", "\\\"")).append("\""); } } } @@ -458,7 +471,8 @@ else if (paramaters != null && paramaters.size() > 0) // We simply ignore the issue because it is only a debug feature } - log.debug("Running the HTTP " + callType + " request '" + uri + "'" + sb.toString() + (logCurlCommand == true ? curlSb.toString() : "")); + log.debug( + "Running the HTTP " + callType + " request '" + uri + "'" + sb.toString() + (logCurlCommand == true ? curlSb.toString() : "")); } catch (Exception exception) { @@ -477,8 +491,10 @@ else if (paramaters != null && paramaters.size() > 0) { for (final Entry parameter : paramaters.entrySet()) { - outputStream.writeBytes(URLConnectionWebServiceCaller.HYPHEN_HYPHEN + URLConnectionWebServiceCaller.BOUNDARY); - outputStream.writeBytes(URLConnectionWebServiceCaller.NEW_LINE + "Content-Disposition: form-data; name=\"" + parameter.getKey() + "\""); + outputStream.writeBytes( + URLConnectionWebServiceCaller.HYPHEN_HYPHEN + URLConnectionWebServiceCaller.BOUNDARY); + outputStream.writeBytes( + URLConnectionWebServiceCaller.NEW_LINE + "Content-Disposition: form-data; name=\"" + parameter.getKey() + "\""); outputStream.writeBytes(URLConnectionWebServiceCaller.NEW_LINE + URLConnectionWebServiceCaller.NEW_LINE); outputStream.write(parameter.getValue().getBytes(getContentEncoding())); outputStream.writeBytes(URLConnectionWebServiceCaller.NEW_LINE); @@ -489,7 +505,8 @@ else if (paramaters != null && paramaters.size() > 0) for (final MultipartFile file : files) { outputStream.writeBytes(URLConnectionWebServiceCaller.HYPHEN_HYPHEN + URLConnectionWebServiceCaller.BOUNDARY); - outputStream.writeBytes(URLConnectionWebServiceCaller.NEW_LINE + "Content-Disposition: form-data; name=\"" + file.name + "\"; filename=\"" + file.fileName + "\""); + outputStream.writeBytes( + URLConnectionWebServiceCaller.NEW_LINE + "Content-Disposition: form-data; name=\"" + file.name + "\"; filename=\"" + file.fileName + "\""); outputStream.writeBytes(URLConnectionWebServiceCaller.NEW_LINE + "Content-Type: " + file.contentType); outputStream.writeBytes(URLConnectionWebServiceCaller.NEW_LINE + URLConnectionWebServiceCaller.NEW_LINE); outputStream.flush(); @@ -509,7 +526,8 @@ else if (paramaters != null && paramaters.size() > 0) } } - outputStream.writeBytes(URLConnectionWebServiceCaller.NEW_LINE + URLConnectionWebServiceCaller.HYPHEN_HYPHEN + URLConnectionWebServiceCaller.BOUNDARY + URLConnectionWebServiceCaller.HYPHEN_HYPHEN + URLConnectionWebServiceCaller.NEW_LINE); + outputStream.writeBytes( + URLConnectionWebServiceCaller.NEW_LINE + URLConnectionWebServiceCaller.HYPHEN_HYPHEN + URLConnectionWebServiceCaller.BOUNDARY + URLConnectionWebServiceCaller.HYPHEN_HYPHEN + URLConnectionWebServiceCaller.NEW_LINE); outputStream.writeBytes(URLConnectionWebServiceCaller.NEW_LINE); outputStream.flush(); outputStream.close(); @@ -522,7 +540,8 @@ else if (paramaters != null && paramaters.size() > 0) if ("".equals(body) == false && body != null) { final OutputStream outputStream = httpURLConnection.getOutputStream(); - final BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, getContentEncoding())); + final BufferedWriter bufferedWriter = new BufferedWriter( + new OutputStreamWriter(outputStream, getContentEncoding())); bufferedWriter.write(body); bufferedWriter.flush(); bufferedWriter.close(); @@ -547,19 +566,22 @@ else if (paramaters != null && paramaters.size() > 0) responseHeadersSb.append(","); } - responseHeadersSb.append("(\"").append(header.getKey()).append(": ").append(headerValue.replace("\"", "\\\"")).append("\")"); + responseHeadersSb.append("(\"").append(header.getKey()).append(": ").append( + headerValue.replace("\"", "\\\"")).append("\")"); } } } if (log.isDebugEnabled() == true) { - log.debug("The call to the HTTP " + callType + " request '" + uri + "' took " + (System.currentTimeMillis() - start) + " ms and returned the status code " + responseCode + (responseHeadersSb.length() <= 0 ? "" : " with the HTTP headers:" + responseHeadersSb.toString())); + log.debug( + "The call to the HTTP " + callType + " request '" + uri + "' took " + (System.currentTimeMillis() - start) + " ms and returned the status code " + responseCode + (responseHeadersSb.length() <= 0 ? "" : " with the HTTP headers:" + responseHeadersSb.toString())); } if (!(responseCode >= HttpURLConnection.HTTP_OK && responseCode < HttpURLConnection.HTTP_MULT_CHOICE)) { - if (onStatusCodeNotOk(uri, callType, paramaters, body, httpURLConnection, url, responseCode, responseMessage, attemptsCount + 1) == true) + if (onStatusCodeNotOk(uri, callType, paramaters, body, httpURLConnection, url, responseCode, responseMessage, + attemptsCount + 1) == true) { return performHttpRequest(uri, callType, headers, paramaters, body, files, attemptsCount + 1); } @@ -568,13 +590,6 @@ else if (paramaters != null && paramaters.size() > 0) return httpURLConnection; } - protected HttpURLConnection performHttpRequest(String uri, CallType callType, Map headers, - Map parameters, String body, List files) - throws IOException, CallException - { - return performHttpRequest(uri, callType, headers, parameters, body, files, 0); - } - private String transformPostParametersToDataString(Map params) throws UnsupportedEncodingException {