From 78a699a52aef56c8159304cb3e77ce60d0d7b079 Mon Sep 17 00:00:00 2001 From: John Spaetzel Date: Thu, 4 Feb 2021 13:57:11 -0700 Subject: [PATCH 1/8] backwards compatibility for java 8 --- .travis.yml | 1 + build.gradle | 1 + gradle.properties | 2 +- src/main/java/com/hellosign/sdk/http/Authentication.java | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 02f82720..e87b5c8d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: java jdk: - openjdk11 + - openjdk8 script: - ./gradlew build diff --git a/build.gradle b/build.gradle index 2f532601..81894843 100644 --- a/build.gradle +++ b/build.gradle @@ -83,6 +83,7 @@ repositories { dependencies { compile group: 'org.json', name: 'json', version:'20190722' compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.30' + compile group: 'commons-codec', name: 'commons-codec', version:'1.10' testCompile group: 'junit', name: 'junit', version:'4.13' testCompile group: 'org.slf4j', name: 'slf4j-simple', version:'1.7.30' testCompile group: 'org.mockito', name: 'mockito-core', version:'2.28.2' diff --git a/gradle.properties b/gradle.properties index d4fd8209..7e3e2c66 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,4 +4,4 @@ version = 5.1.0 description = HelloSign Java SDK sourceCompatibility = 11 -targetCompatibility = 11 +targetCompatibility = 1.8 diff --git a/src/main/java/com/hellosign/sdk/http/Authentication.java b/src/main/java/com/hellosign/sdk/http/Authentication.java index 4c1c6d5d..7caf7d4d 100644 --- a/src/main/java/com/hellosign/sdk/http/Authentication.java +++ b/src/main/java/com/hellosign/sdk/http/Authentication.java @@ -2,7 +2,7 @@ import com.hellosign.sdk.HelloSignException; import java.net.HttpURLConnection; -import java.util.Base64; +import org.apache.commons.codec.binary.Base64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -134,7 +134,7 @@ public void authenticate(HttpURLConnection httpConn, String url) { } else if (hasApiKey()) { logger.debug("Using API Key to authenticate"); String apiKey = getApiKey() + ":"; - authorization = "Basic " + Base64.getEncoder().encodeToString(apiKey.getBytes()).trim(); + authorization = "Basic " + Base64.encodeBase64String(apiKey.getBytes()).trim(); } if (authorization != null) { From 8ea126f2fc9797a3684da92792454d1f3fe89b66 Mon Sep 17 00:00:00 2001 From: John Spaetzel Date: Thu, 4 Feb 2021 14:06:06 -0700 Subject: [PATCH 2/8] test out github actions since travis is slow --- .github/workflows/gradle.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/gradle.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 00000000..8172ef9e --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,30 @@ +# This workflow will build a Java project with Gradle +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + # test against latest update of each major Java version, as well as specific updates of LTS versions: + java: [ 8, 9, 10, 11, 12, 13 ] + name: Java ${{ matrix.java }} + steps: + - uses: actions/checkout@v2 + - name: Setup Java + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew build From 5b8e379de1a1d3872011b88b8928d42f1ea83cfd Mon Sep 17 00:00:00 2001 From: John Spaetzel Date: Thu, 4 Feb 2021 14:08:01 -0700 Subject: [PATCH 3/8] change default github action triggeR --- .github/workflows/gradle.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 8172ef9e..778b23be 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -3,11 +3,7 @@ name: Java CI with Gradle -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] +on: [push, pull_request] jobs: build: From c1f277255a9ffe2d933079e5ef57c2d502a00cf1 Mon Sep 17 00:00:00 2001 From: John Spaetzel Date: Thu, 4 Feb 2021 14:11:16 -0700 Subject: [PATCH 4/8] simplify build --- .github/workflows/gradle.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 778b23be..783669e7 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -3,7 +3,10 @@ name: Java CI with Gradle -on: [push, pull_request] +on: + push: + branches: [ master ] + pull_request: jobs: build: @@ -12,7 +15,7 @@ jobs: strategy: matrix: # test against latest update of each major Java version, as well as specific updates of LTS versions: - java: [ 8, 9, 10, 11, 12, 13 ] + java: [ 8, 11 ] name: Java ${{ matrix.java }} steps: - uses: actions/checkout@v2 From ccc8c2e4cd5a55ebd91900dfa7ff4814b15054ff Mon Sep 17 00:00:00 2001 From: John Spaetzel Date: Thu, 4 Feb 2021 14:23:03 -0700 Subject: [PATCH 5/8] backwards compatibility changes for strings & vars, remove travis --- .travis.yml | 8 -------- build.gradle | 1 + src/main/java/com/hellosign/sdk/http/HttpClient.java | 3 ++- .../hellosign/sdk/resource/TemplateSignatureRequest.java | 7 ++++--- .../com/hellosign/sdk/resource/support/Attachment.java | 6 ++++-- src/test/java/com/hellosign/sdk/HelloSignClientTest.java | 4 +++- 6 files changed, 14 insertions(+), 15 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e87b5c8d..00000000 --- a/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: java - -jdk: - - openjdk11 - - openjdk8 - -script: - - ./gradlew build diff --git a/build.gradle b/build.gradle index 81894843..1f6e926e 100644 --- a/build.gradle +++ b/build.gradle @@ -84,6 +84,7 @@ dependencies { compile group: 'org.json', name: 'json', version:'20190722' compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.30' compile group: 'commons-codec', name: 'commons-codec', version:'1.10' + compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.11' testCompile group: 'junit', name: 'junit', version:'4.13' testCompile group: 'org.slf4j', name: 'slf4j-simple', version:'1.7.30' testCompile group: 'org.mockito', name: 'mockito-core', version:'2.28.2' diff --git a/src/main/java/com/hellosign/sdk/http/HttpClient.java b/src/main/java/com/hellosign/sdk/http/HttpClient.java index 2911dc5f..f63ba08d 100644 --- a/src/main/java/com/hellosign/sdk/http/HttpClient.java +++ b/src/main/java/com/hellosign/sdk/http/HttpClient.java @@ -13,6 +13,7 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; +import org.apache.commons.lang3.StringUtils; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; @@ -194,7 +195,7 @@ public File asFile(String fileName) throws HelloSignException { private File createTemporaryFile(String filename) throws HelloSignException { String prefix = filename.substring(0, filename.indexOf(".")); String postfix = filename.substring(filename.indexOf(".") + 1); - if (prefix.isBlank() || postfix.isBlank()) { + if (StringUtils.isBlank(prefix) || StringUtils.isBlank(postfix)) { throw new HelloSignException("Invalid file name: " + prefix + "." + postfix); } File f; diff --git a/src/main/java/com/hellosign/sdk/resource/TemplateSignatureRequest.java b/src/main/java/com/hellosign/sdk/resource/TemplateSignatureRequest.java index c1404eb7..ee5a9008 100644 --- a/src/main/java/com/hellosign/sdk/resource/TemplateSignatureRequest.java +++ b/src/main/java/com/hellosign/sdk/resource/TemplateSignatureRequest.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; /** * Represents a HelloSign signature request based on one or more Templates. @@ -135,7 +136,7 @@ public void removeSignerByEmail(String email) { if (email == null) { return; } - var signerSet = signers.entrySet(); + Set> signerSet = signers.entrySet(); for (Entry entry : signerSet) { if (email.equalsIgnoreCase(entry.getValue().getEmail())) { signers.remove(entry.getKey()); @@ -236,7 +237,7 @@ public Map getPostFields() throws HelloSignException { } Map signerz = getSigners(); for (Entry entry : signerz.entrySet()) { - var role = entry.getKey(); + String role = entry.getKey(); Signer s = signerz.get(role); fields.put(TEMPLATE_SIGNERS + "[" + role + "][" + TEMPLATE_SIGNERS_EMAIL + "]", s.getEmail()); @@ -259,7 +260,7 @@ public Map getPostFields() throws HelloSignException { } Map ccz = getCCs(); for (Entry entry : ccz.entrySet()) { - var role = entry.getKey(); + String role = entry.getKey(); fields.put(TEMPLATE_CCS + "[" + role + "][" + TEMPLATE_CCS_EMAIL + "]", ccz.get(role)); } diff --git a/src/main/java/com/hellosign/sdk/resource/support/Attachment.java b/src/main/java/com/hellosign/sdk/resource/support/Attachment.java index b470a754..4ba7f307 100644 --- a/src/main/java/com/hellosign/sdk/resource/support/Attachment.java +++ b/src/main/java/com/hellosign/sdk/resource/support/Attachment.java @@ -1,5 +1,7 @@ package com.hellosign.sdk.resource.support; +import org.apache.commons.lang3.StringUtils; + public class Attachment { String name; String instructions; @@ -34,7 +36,7 @@ public String getInstructions() { } public void setInstructions(String instructions) { - if(!instructions.isBlank()){ + if(!StringUtils.isBlank(instructions)){ this.instructions = instructions; } } @@ -73,7 +75,7 @@ public String getName() { } public void setName(String name) { - if(!name.isBlank()){ + if(!StringUtils.isBlank(name)){ this.name = name; } } diff --git a/src/test/java/com/hellosign/sdk/HelloSignClientTest.java b/src/test/java/com/hellosign/sdk/HelloSignClientTest.java index a7f05791..eb435148 100644 --- a/src/test/java/com/hellosign/sdk/HelloSignClientTest.java +++ b/src/test/java/com/hellosign/sdk/HelloSignClientTest.java @@ -47,7 +47,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Scanner; +import java.util.Set; import java.util.regex.Pattern; import java.util.Arrays; import org.json.JSONArray; @@ -1115,7 +1117,7 @@ public void testRemovingSignersByEmail() throws HelloSignException { request.setSigner("role", "john@example.com", "John"); request.removeSignerByEmail("john@example.com"); Map signers = request.getSigners(); - var set = signers.entrySet(); + Set> set = signers.entrySet(); Assert.assertEquals(0, set.size()); } From 069de31bf44682228d1ce306b9155616a345178d Mon Sep 17 00:00:00 2001 From: John Spaetzel Date: Thu, 4 Feb 2021 14:24:49 -0700 Subject: [PATCH 6/8] add ci checks for java 9-13 --- .github/workflows/gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 783669e7..b36e01e5 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: # test against latest update of each major Java version, as well as specific updates of LTS versions: - java: [ 8, 11 ] + java: [ 8, 9, 10, 11, 12, 13 ] name: Java ${{ matrix.java }} steps: - uses: actions/checkout@v2 From 834bdf3b42a1b42b996b951945bcf4dcd1c73be0 Mon Sep 17 00:00:00 2001 From: John Spaetzel Date: Thu, 4 Feb 2021 14:26:43 -0700 Subject: [PATCH 7/8] remove java 13 which is incompatible with gradle 5 --- .github/workflows/gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index b36e01e5..68b76526 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: # test against latest update of each major Java version, as well as specific updates of LTS versions: - java: [ 8, 9, 10, 11, 12, 13 ] + java: [ 8, 9, 10, 11, 12 ] name: Java ${{ matrix.java }} steps: - uses: actions/checkout@v2 From 6a8b82adde81d59f8b41f0f5dfcebbf790bd3e0d Mon Sep 17 00:00:00 2001 From: John Spaetzel Date: Thu, 4 Feb 2021 14:30:39 -0700 Subject: [PATCH 8/8] cleanup gradle warnings --- .../java/com/hellosign/sdk/resource/AbstractResource.java | 1 - .../java/com/hellosign/sdk/resource/BulkSendJobById.java | 6 +----- src/main/java/com/hellosign/sdk/resource/BulkSendJobs.java | 4 ---- src/main/java/com/hellosign/sdk/resource/TemplateDraft.java | 1 - .../java/com/hellosign/sdk/resource/support/Attachment.java | 2 -- src/test/java/com/hellosign/sdk/HelloSignClientTest.java | 5 ----- 6 files changed, 1 insertion(+), 18 deletions(-) diff --git a/src/main/java/com/hellosign/sdk/resource/AbstractResource.java b/src/main/java/com/hellosign/sdk/resource/AbstractResource.java index 89a7920a..0eb6976b 100644 --- a/src/main/java/com/hellosign/sdk/resource/AbstractResource.java +++ b/src/main/java/com/hellosign/sdk/resource/AbstractResource.java @@ -158,7 +158,6 @@ protected List getList(Class clazz, String key) { * @param obj Provide Object needs to be type casted. * @param key Key for Object. * @param Object - * @return */ protected Object getObject(Class Class, Object obj, String key){ diff --git a/src/main/java/com/hellosign/sdk/resource/BulkSendJobById.java b/src/main/java/com/hellosign/sdk/resource/BulkSendJobById.java index ab7bd371..5c4f8e60 100644 --- a/src/main/java/com/hellosign/sdk/resource/BulkSendJobById.java +++ b/src/main/java/com/hellosign/sdk/resource/BulkSendJobById.java @@ -26,16 +26,13 @@ public BulkSendJobById(JSONObject json) throws HelloSignException{ /** * Get bulk_send_job Object. - * @return - * @throws Exception */ - public BulkSendJobs getBulkSendJob() throws Exception{ + public BulkSendJobs getBulkSendJob() throws Exception { return (BulkSendJobs) getObject(BulkSendJobs.class, dataObj.get(BULKSENDJOB), BULKSENDJOB); } /** * Get list_info Object. - * @return */ public Object getListInfo() { return getJSONObject().get(LIST_INFO); @@ -43,7 +40,6 @@ public Object getListInfo() { /** * Get List of signature_requests. - * @return */ public List getSignatureRequests(){ return getList(SignatureRequest.class, SIGNATURE_REQUESTS); diff --git a/src/main/java/com/hellosign/sdk/resource/BulkSendJobs.java b/src/main/java/com/hellosign/sdk/resource/BulkSendJobs.java index 12bad0c4..5c367fa7 100644 --- a/src/main/java/com/hellosign/sdk/resource/BulkSendJobs.java +++ b/src/main/java/com/hellosign/sdk/resource/BulkSendJobs.java @@ -23,7 +23,6 @@ public BulkSendJobs(JSONObject jsonObject)throws HelloSignException{ /** * Get Bulk send job id. - * @return */ public String getBulkSendJobId() { return getString(BULKSENDJOB_ID); @@ -31,7 +30,6 @@ public String getBulkSendJobId() { /** * Get Bulk send job total. - * @return */ public String getBulkSendJobTotal() { return getString(BULKSENDJOB_TOTAL); @@ -39,7 +37,6 @@ public String getBulkSendJobTotal() { /** * Get Bulk send job is Creator. - * @return */ public Boolean getBulkSendJobIsCreator() { return getBoolean(BULKSENDJOB_ISCREATOR); @@ -47,7 +44,6 @@ public Boolean getBulkSendJobIsCreator() { /** * Get Bulk send job created at. - * @return */ public Date getBulkSendJobCreatedAt() { return getDate(BULKSENDJOB_CREATEDAT); diff --git a/src/main/java/com/hellosign/sdk/resource/TemplateDraft.java b/src/main/java/com/hellosign/sdk/resource/TemplateDraft.java index ba760adc..e40dced5 100644 --- a/src/main/java/com/hellosign/sdk/resource/TemplateDraft.java +++ b/src/main/java/com/hellosign/sdk/resource/TemplateDraft.java @@ -53,7 +53,6 @@ public List getAttachments() { /** * Set List of Attachments to the request. - * @param attachments */ public void setAttachments(List attachments) { this.attachments = attachments; diff --git a/src/main/java/com/hellosign/sdk/resource/support/Attachment.java b/src/main/java/com/hellosign/sdk/resource/support/Attachment.java index 4ba7f307..f1425aa3 100644 --- a/src/main/java/com/hellosign/sdk/resource/support/Attachment.java +++ b/src/main/java/com/hellosign/sdk/resource/support/Attachment.java @@ -29,7 +29,6 @@ public Attachment(String name, String instructions, int signer_index, boolean is /** * Get Instruction for signer. - * @return */ public String getInstructions() { return instructions; @@ -49,7 +48,6 @@ public int getSigner() { * Provide signer_index, in accordance to the order, signer is added. * Example : first signer : signer_index = 0 * second signer : signer_index = 1 - * @param signer_index */ public void setSigner_index(int signer_index) { this.signer_index= signer_index; diff --git a/src/test/java/com/hellosign/sdk/HelloSignClientTest.java b/src/test/java/com/hellosign/sdk/HelloSignClientTest.java index eb435148..84b5bd5f 100644 --- a/src/test/java/com/hellosign/sdk/HelloSignClientTest.java +++ b/src/test/java/com/hellosign/sdk/HelloSignClientTest.java @@ -1123,7 +1123,6 @@ public void testRemovingSignersByEmail() throws HelloSignException { /** * Test for Get bulk send job list. - * @throws Exception */ @Test public void testGetBulkSendJobList() throws Exception { @@ -1143,7 +1142,6 @@ public void testGetBulkSendJobList() throws Exception { /** * Test for Get bulk send job list with Page. - * @throws Exception */ @Test public void testGetBulkSendJobListWithPage() throws Exception { @@ -1163,7 +1161,6 @@ public void testGetBulkSendJobListWithPage() throws Exception { /** * Test for Get bulk send job list with Page and Page size. - * @throws Exception */ @Test public void testGetBulkSendJobListWithPageAndSize() throws Exception { @@ -1183,7 +1180,6 @@ public void testGetBulkSendJobListWithPageAndSize() throws Exception { /** * Test for Get bulk send job by id. - * @throws Exception */ @Test public void testGetBulkSendJobById() throws Exception { @@ -1205,7 +1201,6 @@ public void testGetBulkSendJobById() throws Exception { /** * Test to verify Remove your access to a completed signature request. - * @throws Exception */ @Test public void testRemoveSignatureRequestAccess() throws Exception {