Commit fe5db68a authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '11-java-11' into 'master'

Resolve "Java 11"

Closes #11

See merge request !14
parents 92b1cbaf b0ea63d4
Pipeline #16368 passed with stage
in 36 seconds
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\-/
# 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
......
......@@ -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 {
<dependency>
<groupId>org.genesys-pgr</groupId>
<artifactId>genesys-client-api</artifactId>
<version>1.4</version>
<version>2.0</version>
</dependency>
```
Or for the development version:
Or for the development version (Java 11):
```xml
<dependency>
<groupId>org.genesys-pgr</groupId>
<artifactId>genesys-client-api</artifactId>
<version>2.0-SNAPSHOT</version>
<version>3.0-SNAPSHOT</version>
</dependency>
```
......
......@@ -3,10 +3,10 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.genesys-pgr</groupId>
<artifactId>genesys-client-api</artifactId>
<version>2.0-SNAPSHOT</version>
<version>3.0-SNAPSHOT</version>
<name>Genesys API client library</name>
<packaging>jar</packaging>
<url>https://bitbucket.org/genesys2/genesys-client-api</url>
<url>https://gitlab.croptrust.org/genesys-pgr/genesys-client-api</url>
<description>Java client for Genesys PGR Server APIs</description>
<licenses>
......@@ -17,9 +17,9 @@
</licenses>
<scm>
<connection>https://bitbucket.org/genesys2/genesys-client-api.git</connection>
<developerConnection>scm:git:git@bitbucket.org:genesys2/genesys-client-api.git</developerConnection>
<url>git@bitbucket.org:genesys2/genesys-client-api.git</url>
<connection>https://gitlab.croptrust.org/genesys-pgr/genesys-client-api.git</connection>
<developerConnection>scm:git:git@gitlab.croptrust.org:genesys-pgr/genesys-client-api.git</developerConnection>
<url>git@gitlab.croptrust.org:genesys-pgr/genesys-client-api.git</url>
<tag>HEAD</tag>
</scm>
......@@ -34,12 +34,12 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.target>1.8</jdk.target>
<jdk.source>1.8</jdk.source>
<jdk.target>11</jdk.target>
<jdk.source>11</jdk.source>
<maven-gpg-plugin.version>1.5</maven-gpg-plugin.version>
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
<slf4j.version>1.7.21</slf4j.version>
<slf4j.version>1.7.30</slf4j.version>
<show.deprecations>true</show.deprecations>
</properties>
......@@ -93,11 +93,11 @@
<artifactId>scribejava-core</artifactId>
<version>6.2.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
......@@ -106,17 +106,17 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.4</version>
<version>2.11.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
......@@ -134,7 +134,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.6</version>
<version>4.5.13</version>
<scope>test</scope>
</dependency>
</dependencies>
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -48,12 +48,12 @@ public class MockGenesysServer {
private final Map<String, List<AccessionJson>> instAcc = new HashMap<String, List<AccessionJson>>();
/** 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);
}
......
......@@ -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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment