diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 20dbe077639a019c4131d3ad38dd76b1ac66f028..9a2ea2968f9589e84cbdedcca9e71d6beafc22e4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,34 +1,43 @@
+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
run tests in branches:
stage: compile
- image: maven:3-jdk-8
+ image: maven:3-openjdk-11
script:
- - MAVEN_OPTS="${MAVEN_OPTS} -Dorg.slf4j.simpleLogger.defaultLogLevel=warn" mvn test -B
+ - mvn $MAVEN_CLI_OPTS test -B
except:
- master
- /^genesys\-client\-api\-/
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
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
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
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 e584b5a13f2f4894e1b5c1d52807f569639674d7..82835ca5761b5c119585f5c13429231bde27d15a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,22 @@
# 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.
+
+- 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 e0d452b060919154f4a5642b8bc0522754725e28..53b7b646bb41066759cef40bb9838a014f1f9ab2 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,17 +109,17 @@ try {
org.genesys-pgr
genesys-client-api
- 1.4
+ 2.0
```
-Or for the development version:
+Or for the development version (Java 11):
```xml
org.genesys-pgr
genesys-client-api
- 2.0-SNAPSHOT
+ 3.0-SNAPSHOT
```
diff --git a/pom.xml b/pom.xml
index 3c656bdd25259ad2d3f1a263ea79b8c4175f6388..f7dc383b8b8d2a664fa24133aba61e32f0b76f55 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,10 +3,10 @@
4.0.0
org.genesys-pgr
genesys-client-api
- 2.0-SNAPSHOT
+ 3.0-SNAPSHOT
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,9 +17,9 @@
- 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
+ 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
HEAD
@@ -34,12 +34,12 @@
UTF-8
- 1.8
- 1.8
+ 11
+ 11
1.5
1.6.8
- 1.7.21
+ 1.7.30
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
@@ -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 24d29f7a892c24b67d70974bad5b7adfd7f477e2..785e3c76cb22719ea6c47c2f109435cf59504c5c 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 e9c12c8ac95a39e24f4b842ff41fa4d9a5648fd0..75c9bedefac1440ef803a7e5c181e556a47dd713 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 00daf186d5b5ea8b09a37dee883bc67c20fa5612..0e76807a8eb9bd0188a84e28c59a21eb2b4b4d5b 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 57030eb6ef6da7a064ce659b026f8faf3ce326c5..f77b7e6a65d8660d262806465050f6b3f5b64232 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 6c71e147d15619f2e7da80cb048d7e969694b9fb..54d3345fa6d4f561e0b8f338a19d131acc833d56 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);
}