From 8e5e3b578236e5bf8dff29096feabce7ee26e63c Mon Sep 17 00:00:00 2001 From: Ludovic Roland Date: Mon, 5 Feb 2018 16:59:01 +0100 Subject: [PATCH 1/2] RED-149 #time 30m Work on the onStatusCodeNotOk method in order to manage some token in headers --- library/build.gradle | 7 ++----- .../droid4me/ws/URLConnectionWebServiceCaller.java | 9 ++++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/library/build.gradle b/library/build.gradle index 1570a208..a88bc730 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -17,8 +17,8 @@ android minSdkVersion 14 targetSdkVersion 27 - versionCode 21 - versionName "2.6.0" + versionCode 22 + versionName "2.7.0" } buildTypes @@ -128,9 +128,6 @@ publishing.publications.all bintray { - user = bintrayUsername - key = bintrayKey - publications = ["ReleasePublication"] pkg diff --git a/library/src/main/java/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java b/library/src/main/java/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java index e8471e41..bc6b07b9 100644 --- a/library/src/main/java/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java +++ b/library/src/main/java/com/smartnsoft/droid4me/ws/URLConnectionWebServiceCaller.java @@ -197,6 +197,7 @@ protected int getConnectTimeout() * @param callType the type of the HTTP method * @param postParameters the body (as form-data fields) of the HTTP method when its a {@link CallType#Post} or a {@link CallType#Put} ; {@code null} * otherwise + * @param headers the original headers of the request. They can be edited in order to manage some scenarios with tokens * @param body the body (as form-data fields) of the HTTP method when its a {@link CallType#Post} or a {@link CallType#Put} ; {@code null} * otherwise * @param httpURLConnection the HttpURLConnection object @@ -206,7 +207,8 @@ protected int getConnectTimeout() * @return {@code true} if you want the request to be re-run if it has failed * @throws CallException if you want the call to be considered as not OK */ - protected boolean onStatusCodeNotOk(String uri, CallType callType, Map postParameters, String body, + protected boolean onStatusCodeNotOk(String uri, CallType callType, Map postParameters, + Map headers, String body, HttpURLConnection httpURLConnection, URL url, int statusCode, String statusMessage, int attemptsCount) throws CallException { @@ -472,7 +474,8 @@ protected HttpURLConnection performHttpRequest(String uri, CallType callType, Ma return performHttpRequest(uri, callType, headers, parameters, body, files, 0); } - protected boolean shouldTryToConsumeErrorInputstream(int statusCode, String uri, CallType callType, Map headers, + protected boolean shouldTryToConsumeErrorInputstream(int statusCode, String uri, CallType callType, + Map headers, Map parameters, String body, List files) { return false; @@ -733,7 +736,7 @@ else if (paramaters != null && paramaters.size() > 0) if (!(responseCode >= HttpURLConnection.HTTP_OK && responseCode < HttpURLConnection.HTTP_MULT_CHOICE)) { - if (onStatusCodeNotOk(uri, callType, paramaters, body, httpURLConnection, url, responseCode, responseMessage, + if (onStatusCodeNotOk(uri, callType, paramaters, headers, body, httpURLConnection, url, responseCode, responseMessage, attemptsCount + 1) == true) { return performHttpRequest(uri, callType, headers, paramaters, body, files, attemptsCount + 1); From aebc7ef6a12590bdfbce20e792d4cd993da4afdc Mon Sep 17 00:00:00 2001 From: Ludovic Roland Date: Fri, 9 Feb 2018 14:29:25 +0100 Subject: [PATCH 2/2] RED-149 #time 15m Prepare the release of the version 2.7.0 --- library/build.gradle | 2 +- sample/build.gradle | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/library/build.gradle b/library/build.gradle index a88bc730..8ba4a691 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -5,7 +5,7 @@ apply plugin: "maven-publish" ext { - appCompatVersion="27.0.1" + appCompatVersion="27.0.2" } android diff --git a/sample/build.gradle b/sample/build.gradle index e7628eef..ad4526f6 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -2,15 +2,14 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 26 - buildToolsVersion "26.0.2" + compileSdkVersion 27 defaultConfig { applicationId "com.smartnsoft.sample" minSdkVersion 16 - targetSdkVersion 26 + targetSdkVersion 27 versionCode 1 versionName "1.0" @@ -29,6 +28,6 @@ android dependencies { - implementation ("com.android.support:appcompat-v7:27.0.1") + implementation ("com.android.support:appcompat-v7:27.0.2") implementation (project(":library")) }