From d380fb3d3669fb363aa8f7f02486b09bc0c4ac53 Mon Sep 17 00:00:00 2001 From: Maxym Borodenko Date: Mon, 11 Jan 2021 16:34:32 +0200 Subject: [PATCH 1/5] [maven-release-plugin] prepare release genesys-client-api-2.0 --- .gitlab-ci.yml | 15 ++++++++++++--- CHANGELOG.md | 13 +++++++++++++ README.md | 25 +++++++++++++++++++++---- pom.xml | 24 ++++++++++++------------ 4 files changed, 58 insertions(+), 19 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 20dbe07..7554f5e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,12 @@ +variables: + # This will suppress any download for dependencies and plugins or upload messages which would clutter the console log. + # `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work. + MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" + # As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used + # when running from the command line. + # `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins. + MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true" + stages: - compile - deploy @@ -6,7 +15,7 @@ run tests in branches: stage: compile image: maven:3-jdk-8 script: - - MAVEN_OPTS="${MAVEN_OPTS} -Dorg.slf4j.simpleLogger.defaultLogLevel=warn" mvn test -B + - mvn $MAVEN_CLI_OPTS test -B except: - master - /^genesys\-client\-api\-/ @@ -18,7 +27,7 @@ publish snapshot artifacts: - echo "${GPG_KEY_SECRET}" | gpg --batch --import - gpg --list-keys script: - - mvn clean deploy --settings .ci-maven-settings.xml -B -U + - mvn $MAVEN_CLI_OPTS clean deploy --settings .ci-maven-settings.xml -B -U only: - master @@ -29,6 +38,6 @@ publish artifacts on central: - echo "${GPG_KEY_SECRET}" | gpg --batch --import - gpg --list-keys script: - - mvn -e -X -P release clean deploy --settings .ci-maven-settings.xml -B -U + - mvn $MAVEN_CLI_OPTS -e -P release clean deploy --settings .ci-maven-settings.xml -B -U only: - /^genesys\-client\-api\-/ diff --git a/CHANGELOG.md b/CHANGELOG.md index e584b5a..4e1b25c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Genesys Client API changelog +## Release 2.0 + +January 2021, the last version of the library with Java 8. + +- b87ea2c Added new constant for Data provider ID +- 1f9151e Added constant for New WIEWS code +- ef6d3fc Added aegis to AccessionJson +- e75f511 Updated unit tests for "taxonomy" object +- c12b604 Field names changed +- ed48f4a Code cleanup +- 034bbb7 added taxonomy constants, fixed auth endpoint name +- b573448 Use API v1 endpoints + ## Release 1.4 April 2019 diff --git a/README.md b/README.md index e0d452b..77eafb9 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ ```java // Set server URL -String baseUrl = "https://www.genesys-pgr.org"; +String baseUrl = "https://api.sandbox.genesys-pgr.org"; +// String baseUrl = "https://api.genesys-pgr.org"; String clientId = "theClientId@genesys"; String clientSecret = "thesecret"; String callbackUrl = "oob"; @@ -14,6 +15,22 @@ String scope = "write"; // write scope is required to manage data on Genesys GenesysClient genesysClient = new GenesysClient(baseUrl, clientId, clientSecret, callbackUrl, scope); ``` +### System-to-system authentication + +For Genesys API clients that support **OAuth client credentials**: + +```java +// Use client_id and secret to authenticate +genesysClient.authenticate(); + +// Test it with /me +genesysClient.me(); + +// Tokens are now accessible. The refreshToken must be **safely** stored for future use. +// genesysClient.getTokens().getAccessToken(); +// genesysClient.getTokens().getRefreshToken(); +``` + ### Authentication: Authorization code For Genesys API clients that support `authorization_code` grant (such as websites, unsafe clients). @@ -36,7 +53,7 @@ genesysClient.me(); ### Authentication: Username and password -For Genesys API clients that support `password` grant (safe clients). +For Genesys API clients that support **OAuth password grant** (safe clients). ```java // Obtain username and password @@ -92,7 +109,7 @@ try { org.genesys-pgr genesys-client-api - 1.4 + 2.0 ``` @@ -102,7 +119,7 @@ Or for the development version: org.genesys-pgr genesys-client-api - 2.0-SNAPSHOT + 3.0-SNAPSHOT ``` diff --git a/pom.xml b/pom.xml index 3c656bd..558a617 100644 --- a/pom.xml +++ b/pom.xml @@ -3,10 +3,10 @@ 4.0.0 org.genesys-pgr genesys-client-api - 2.0-SNAPSHOT + 2.0 Genesys API client library jar - https://bitbucket.org/genesys2/genesys-client-api + https://gitlab.croptrust.org/genesys-pgr/genesys-client-api Java client for Genesys PGR Server APIs @@ -17,10 +17,10 @@ - https://bitbucket.org/genesys2/genesys-client-api.git - scm:git:git@bitbucket.org:genesys2/genesys-client-api.git - git@bitbucket.org:genesys2/genesys-client-api.git - HEAD + https://gitlab.croptrust.org/genesys-pgr/genesys-client-api.git + scm:git:git@gitlab.croptrust.org:genesys-pgr/genesys-client-api.git + git@gitlab.croptrust.org:genesys-pgr/genesys-client-api.git + genesys-client-api-2.0 @@ -39,7 +39,7 @@ 1.5 1.6.8 - 1.7.21 + 1.7.21 true @@ -93,11 +93,11 @@ scribejava-core 6.2.0 - - org.slf4j - jcl-over-slf4j - ${slf4j.version} - + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + commons-lang commons-lang -- GitLab From fb1915ab60ad2d39c2197a3100616c3648266c36 Mon Sep 17 00:00:00 2001 From: Maxym Borodenko Date: Mon, 11 Jan 2021 16:36:47 +0200 Subject: [PATCH 2/5] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 558a617..8ca27d9 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.genesys-pgr genesys-client-api - 2.0 + 3.0-SNAPSHOT Genesys API client library jar https://gitlab.croptrust.org/genesys-pgr/genesys-client-api @@ -20,7 +20,7 @@ https://gitlab.croptrust.org/genesys-pgr/genesys-client-api.git scm:git:git@gitlab.croptrust.org:genesys-pgr/genesys-client-api.git git@gitlab.croptrust.org:genesys-pgr/genesys-client-api.git - genesys-client-api-2.0 + HEAD -- GitLab From 47de510f73e5c19b052d7a92607dcdc1931f6446 Mon Sep 17 00:00:00 2001 From: Maxym Borodenko Date: Mon, 11 Jan 2021 17:24:28 +0200 Subject: [PATCH 3/5] Java 11 --- .gitlab-ci.yml | 6 +++--- pom.xml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7554f5e..9a2ea29 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,7 +13,7 @@ stages: run tests in branches: stage: compile - image: maven:3-jdk-8 + image: maven:3-openjdk-11 script: - mvn $MAVEN_CLI_OPTS test -B except: @@ -22,7 +22,7 @@ run tests in branches: publish snapshot artifacts: stage: deploy - image: maven:3-jdk-8 + image: maven:3-openjdk-11 before_script: - echo "${GPG_KEY_SECRET}" | gpg --batch --import - gpg --list-keys @@ -33,7 +33,7 @@ publish snapshot artifacts: publish artifacts on central: stage: deploy - image: maven:3-jdk-8 + image: maven:3-openjdk-11 before_script: - echo "${GPG_KEY_SECRET}" | gpg --batch --import - gpg --list-keys diff --git a/pom.xml b/pom.xml index 8ca27d9..d998d8e 100644 --- a/pom.xml +++ b/pom.xml @@ -34,8 +34,8 @@ UTF-8 - 1.8 - 1.8 + 11 + 11 1.5 1.6.8 -- GitLab From 6281e4856bcb5491e2fcb8d4838e3e2232329dce Mon Sep 17 00:00:00 2001 From: Maxym Borodenko Date: Mon, 11 Jan 2021 17:42:29 +0200 Subject: [PATCH 4/5] Dependency updates --- pom.xml | 10 +++++----- .../java/org/genesys2/client/oauth/GenesysClient.java | 9 +++++---- .../org/geneys2/client/oauth/AccessionApiTest.java | 4 ++-- src/test/java/org/geneys2/client/oauth/ApiTest.java | 4 ++-- .../org/geneys2/client/oauth/MockGenesysServer.java | 4 ++-- src/test/java/org/geneys2/client/oauth/ModelTests.java | 4 ++-- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/pom.xml b/pom.xml index d998d8e..f7dc383 100644 --- a/pom.xml +++ b/pom.xml @@ -39,7 +39,7 @@ 1.5 1.6.8 - 1.7.21 + 1.7.30 true @@ -106,17 +106,17 @@ commons-io commons-io - 2.4 + 2.8.0 com.fasterxml.jackson.core jackson-databind - 2.6.4 + 2.11.4 junit junit - 4.12 + 4.13.1 test @@ -134,7 +134,7 @@ org.apache.httpcomponents httpclient - 4.3.6 + 4.5.13 test diff --git a/src/main/java/org/genesys2/client/oauth/GenesysClient.java b/src/main/java/org/genesys2/client/oauth/GenesysClient.java index 24d29f7..785e3c7 100644 --- a/src/main/java/org/genesys2/client/oauth/GenesysClient.java +++ b/src/main/java/org/genesys2/client/oauth/GenesysClient.java @@ -22,6 +22,7 @@ import java.io.Serializable; import java.net.URI; import java.net.URISyntaxException; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -66,7 +67,7 @@ public class GenesysClient { private static final Logger LOG = LoggerFactory.getLogger(GenesysClient.class); /** The mapper. */ - private static ObjectMapper objectMapper; + private static final ObjectMapper objectMapper; /** The service. */ private final OAuth20Service service; @@ -75,15 +76,15 @@ public class GenesysClient { private GenesysTokens tokens = new GenesysTokens(); /** Base URL of Genesys */ - private String baseUrl; + private final String baseUrl; /** UTF8 charset */ - private static Charset CHARSET_UTF8 = Charset.forName("UTF8"); + private static final Charset CHARSET_UTF8 = StandardCharsets.UTF_8; static { objectMapper = new ObjectMapper(); objectMapper.configure(SerializationFeature.WRITE_ENUMS_USING_TO_STRING, true); - objectMapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false); + objectMapper.setSerializationInclusion(Include.NON_EMPTY); objectMapper.setSerializationInclusion(Include.NON_NULL); objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); } diff --git a/src/test/java/org/geneys2/client/oauth/AccessionApiTest.java b/src/test/java/org/geneys2/client/oauth/AccessionApiTest.java index e9c12c8..75c9bed 100644 --- a/src/test/java/org/geneys2/client/oauth/AccessionApiTest.java +++ b/src/test/java/org/geneys2/client/oauth/AccessionApiTest.java @@ -51,7 +51,7 @@ import com.fasterxml.jackson.databind.SerializationFeature; public class AccessionApiTest { /** The object mapper. */ - private static ObjectMapper objectMapper; + private static final ObjectMapper objectMapper; /** The genesys client. */ @Mock @@ -66,7 +66,7 @@ public class AccessionApiTest { static { objectMapper = new ObjectMapper(); objectMapper.configure(SerializationFeature.WRITE_ENUMS_USING_TO_STRING, true); - objectMapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false); + objectMapper.setSerializationInclusion(Include.NON_EMPTY); objectMapper.setSerializationInclusion(Include.NON_NULL); } diff --git a/src/test/java/org/geneys2/client/oauth/ApiTest.java b/src/test/java/org/geneys2/client/oauth/ApiTest.java index 00daf18..0e76807 100644 --- a/src/test/java/org/geneys2/client/oauth/ApiTest.java +++ b/src/test/java/org/geneys2/client/oauth/ApiTest.java @@ -52,7 +52,7 @@ import com.github.scribejava.core.model.Verb; public class ApiTest { /** The object mapper. */ - private static ObjectMapper objectMapper; + private static final ObjectMapper objectMapper; /** The http get mock. */ @Mock @@ -69,7 +69,7 @@ public class ApiTest { static { objectMapper = new ObjectMapper(); objectMapper.configure(SerializationFeature.WRITE_ENUMS_USING_TO_STRING, true); - objectMapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false); + objectMapper.setSerializationInclusion(Include.NON_EMPTY); objectMapper.setSerializationInclusion(Include.NON_NULL); } diff --git a/src/test/java/org/geneys2/client/oauth/MockGenesysServer.java b/src/test/java/org/geneys2/client/oauth/MockGenesysServer.java index 57030eb..f77b7e6 100644 --- a/src/test/java/org/geneys2/client/oauth/MockGenesysServer.java +++ b/src/test/java/org/geneys2/client/oauth/MockGenesysServer.java @@ -48,12 +48,12 @@ public class MockGenesysServer { private final Map> instAcc = new HashMap>(); /** The object mapper. */ - private static ObjectMapper objectMapper; + private static final ObjectMapper objectMapper; static { objectMapper = new ObjectMapper(); objectMapper.configure(SerializationFeature.WRITE_ENUMS_USING_TO_STRING, true); - objectMapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false); + objectMapper.setSerializationInclusion(Include.NON_EMPTY); objectMapper.setSerializationInclusion(Include.NON_NULL); } diff --git a/src/test/java/org/geneys2/client/oauth/ModelTests.java b/src/test/java/org/geneys2/client/oauth/ModelTests.java index 6c71e14..54d3345 100644 --- a/src/test/java/org/geneys2/client/oauth/ModelTests.java +++ b/src/test/java/org/geneys2/client/oauth/ModelTests.java @@ -41,12 +41,12 @@ import org.junit.Test; public class ModelTests { /** The object mapper. */ - private static ObjectMapper objectMapper; + private static final ObjectMapper objectMapper; static { objectMapper = new ObjectMapper(); objectMapper.configure(SerializationFeature.WRITE_ENUMS_USING_TO_STRING, true); - objectMapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false); + objectMapper.setSerializationInclusion(Include.NON_EMPTY); objectMapper.setSerializationInclusion(Include.NON_NULL); } -- GitLab From b0ea63d46a3bb8b36cd524489653b4e2e9b38b3c Mon Sep 17 00:00:00 2001 From: Matija Obreza Date: Thu, 28 Jan 2021 10:16:46 +0100 Subject: [PATCH 5/5] Docs --- CHANGELOG.md | 4 ++++ README.md | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e1b25c..82835ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Genesys Client API changelog +## Release 3.0-SNAPSHOT + +Updated to Java 11. + ## Release 2.0 January 2021, the last version of the library with Java 8. diff --git a/README.md b/README.md index 77eafb9..53b7b64 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ try { ``` -Or for the development version: +Or for the development version (Java 11): ```xml -- GitLab