Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change to Okhttp #86

Merged
merged 57 commits into from
Mar 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
0b9ee38
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Nov 2, 2017
ace7662
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Nov 10, 2017
948b1f9
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Nov 13, 2017
fdea96a
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Nov 18, 2017
9cbdaf4
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Nov 18, 2017
396efe9
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Nov 22, 2017
b488789
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Nov 27, 2017
f86ccd2
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Dec 10, 2017
b6a758c
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Dec 16, 2017
cbe501d
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Dec 16, 2017
873c1ac
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Dec 21, 2017
2b16393
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Dec 24, 2017
9ec3e74
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Jan 11, 2018
6964dc5
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Jan 11, 2018
0306401
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Jan 13, 2018
496c3ce
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Jan 23, 2018
abdec3c
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Jan 27, 2018
9ed8e9c
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Feb 17, 2018
8b08f25
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Feb 17, 2018
80b6f90
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Feb 24, 2018
bca36db
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu Mar 2, 2018
fc0fc4d
Merge remote-tracking branch 'refs/remotes/burberius/master'
GoldenGnu May 1, 2018
0a235c5
Merge remote-tracking branch 'upstream/master'
GoldenGnu May 5, 2018
63166e1
Line ending changes
GoldenGnu May 20, 2018
cea803d
More line ending stuff
GoldenGnu May 20, 2018
26cf681
Final line ending change
GoldenGnu May 20, 2018
66de995
Merge remote-tracking branch 'upstream/master'
GoldenGnu May 20, 2018
9e2ca70
Merge remote-tracking branch 'upstream/master'
GoldenGnu Jul 29, 2018
c9aa13f
Merge remote-tracking branch 'upstream/master'
GoldenGnu Aug 26, 2018
726518f
Merge remote-tracking branch 'upstream/master'
GoldenGnu Aug 26, 2018
50fe12d
Merge remote-tracking branch 'upstream/master'
GoldenGnu Aug 26, 2018
f7c4b27
Merge remote-tracking branch 'upstream/master'
GoldenGnu Aug 26, 2018
58da9ba
Merge remote-tracking branch 'upstream/master'
GoldenGnu Sep 7, 2018
37d1a46
Merge remote-tracking branch 'upstream/master'
GoldenGnu Sep 7, 2018
7bc556f
Merge remote-tracking branch 'upstream/master'
GoldenGnu Sep 30, 2018
edb63a1
Started on issue 78
GoldenGnu Mar 4, 2019
23f0098
Merge remote-tracking branch 'upstream/master'
GoldenGnu Mar 4, 2019
55d28dd
Better tests
GoldenGnu Mar 4, 2019
2c93b95
Better tests
GoldenGnu Mar 4, 2019
61ba570
More work on issue 78
GoldenGnu Mar 4, 2019
2cd1063
Issue 78
GoldenGnu Mar 4, 2019
cf736e5
Issue 78 formatting
GoldenGnu Mar 4, 2019
c3c47c0
Less sync blocks
GoldenGnu Mar 4, 2019
aa213a4
First commit switching to okhttp
GoldenGnu Mar 5, 2019
11266e6
More work on okhttp
GoldenGnu Mar 5, 2019
58e29c8
swagger codegen 2.3.1
GoldenGnu Mar 5, 2019
7da0d1f
formatting
GoldenGnu Mar 5, 2019
5840c23
Bug Fix for OAuth
GoldenGnu Mar 5, 2019
fd49b92
Ok http (#83)
GoldenGnu Mar 11, 2019
7f7b890
Added fixed openapi-generator.
burberius Mar 11, 2019
3ca4d97
Added new openapi generator and made script executable.
burberius Mar 12, 2019
60b2a7c
Update ApiClient.java
GoldenGnu Mar 12, 2019
c7ff30e
2019-03-11 esi release
GoldenGnu Mar 12, 2019
8cf18a1
ApiClientBuilder (#85)
GoldenGnu Mar 15, 2019
eb16343
Merge branch 'master' into okhttp
burberius Mar 15, 2019
ca8c3e1
Okhttp fixes (#89)
GoldenGnu Mar 17, 2019
7d7388d
Update README.md (#88)
GoldenGnu Mar 17, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ esi.json
/nbactions.xml
/nb-configuration.xml
/src/main/java/net/troja/eve/esi/Main.java
/nbproject/
/nbproject/
meta.json
4 changes: 4 additions & 0 deletions .swagger-codegen-ignore → .openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ LICENSE

# Changed by us
src/main/java/net/troja/eve/esi/auth/OAuth.java
src/main/java/net/troja/eve/esi/api/SwaggerApi.java
src/test/java/net/troja/eve/esi/api/SwaggerApiTest.java
src/main/java/net/troja/eve/esi/api/WebUiApi.java
src/test/java/net/troja/eve/esi/api/WebUIApiTest.java
1 change: 1 addition & 0 deletions .openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3.4
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,17 @@ http://www.thread-safe.com/2014/05/the-correct-use-of-state-parameter-in.html
To run the tests that use authorization you need to have some environment variables set,
this information should not be published:
* SSO_CLIENT_ID
* SSO_CLIENT_SECRET
* SSO_REFRESH_TOKEN

Client id and secret can be created on the following page: https://developers.eveonline.com/
Client id can be created on the following page: https://developers.eveonline.com/
You should use http://localhost as redirect url as that is the value used in the test and it also
makes it easier after the redirect.

### Create a refresh token for the tests
To create a refresh token, you have to start the class *net/troja/eve/esi/api/auth/SsoAuthTest.java*
with your client id as first and the secret as second argument. Then it shows you the url on console.
with your client id as the argument or set the environment variables `SSO_CLIENT_ID`.

Open the url in your browser, login with your account and authorize the access. This will redirect you
The url will open in your browser, login with your account and authorize the access. This will redirect you
to an url on localhost, something like:
```
http://localhost/?code=7z524J_PQZ1YjacS35d8JRkOVwNl-jCvn814xCrgeSm3Acc981lZWW0&state=somesecret
Expand All @@ -55,7 +54,7 @@ Refresh Token: 0tr5SQ-piuKvqjFdDa765DESObTzWKUj5v63KjaL4cTAx041

### Paging
If you wonder how the paging with esi works, please have a look at the test
*[src/test/java/net/troja/eve/esi/api/MarketApiTest.java](https://github.com/burberius/eve-esi/blob/master/src/test/java/net/troja/eve/esi/api/MarketApiTest.java#L49)* there is a method *pagingExample* showing it.
*[src/test/java/net/troja/eve/esi/api/MarketApiTest.java](https://github.com/burberius/eve-esi/blob/master/src/test/java/net/troja/eve/esi/api/MarketApiTest.java#L234)* there is a method *pagingExample* showing it.

### java.lang.IllegalStateException: InjectionManagerFactory not found
When you get that exception with eve-esi, you have to add the following dependency to your *pom.xml*
Expand Down Expand Up @@ -83,5 +82,5 @@ When you get that exception with eve-esi, you have to add the following dependen
2) run ``./generate.sh``

## Links
* [EVE Swagger Interface](https://esi.tech.ccp.is/latest/)
* [Eve Online SSO](http://eveonline-third-party-documentation.readthedocs.io/en/latest/sso/index.html)
* [EVE Swagger Interface](https://esi.evetech.net/)
* [Eve Online SSO](https://github.com/esi/esi-docs#sso---read-this-notice-first)
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"invokerPackage":"net.troja.eve.esi",
"apiPackage":"net.troja.eve.esi.api",
"modelPackage":"net.troja.eve.esi.model",
"library":"jersey2",
"library":"okhttp-gson",
"serializableModel":"true",
"hideGenerationTimestamp":"true",
"dateLibrary":"java8"
Expand Down
20 changes: 17 additions & 3 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
# Get eve swagger file
#
rm -f esi.json
wget -q -O esi.json https://esi.evetech.net/_latest/swagger.json?datasource=tranquility
wget -O esi.json https://esi.evetech.net/_latest/swagger.json?datasource=tranquility
wget -O meta.json https://esi.evetech.net/swagger.json

#
# Remove old model files in case something was removed
#
mv src/main/java/net/troja/eve/esi/model/CharacterInfo.java src/main/java/net/troja/eve/esi/CharacterInfo.java
rm -r src/main/java/net/troja/eve/esi/model
mv src/main/java/net/troja/eve/esi/api/SsoApi.java src/main/java/net/troja/eve/esi/SsoApi.java
rm -r src/main/java/net/troja/eve/esi/api

#
# Get swagger code generator
Expand All @@ -29,19 +33,29 @@ rm -r src/main/java/net/troja/eve/esi/model
# Transform and beautify swagger file
#
sed -i -f replace.sed esi.json
sed -i -f meta_replace.sed meta.json
./meta_transformation.sh
./transformation.sh
#
# Generate code
# Move tests so they are generated new and then moved to a different directory
#
test -d src/test/java/net/troja/eve/esi/api.new && rm -r src/test/java/net/troja/eve/esi/api.new
mv src/test/java/net/troja/eve/esi/api src/test/java/net/troja/eve/esi/api.old
java -jar swagger-codegen-cli.jar generate \
java -jar openapi-generator-cli.jar generate \
--skip-validate-spec \
-i meta.json \
-g java \
-c config.json
java -jar openapi-generator-cli.jar generate \
--skip-validate-spec \
-i esi.json \
-l java \
-g java \
-c config.json
mv src/test/java/net/troja/eve/esi/api src/test/java/net/troja/eve/esi/api.new
mv src/test/java/net/troja/eve/esi/api.old src/test/java/net/troja/eve/esi/api
mv src/main/java/net/troja/eve/esi/CharacterInfo.java src/main/java/net/troja/eve/esi//model/CharacterInfo.java
mv src/main/java/net/troja/eve/esi/SsoApi.java src/main/java/net/troja/eve/esi/api/SsoApi.java

for I in $(grep "OpenAPI spec version" src/* -r | sed -e 's#:.*##'); do
sed -i -e '/OpenAPI spec version/d' $I
Expand Down
3 changes: 3 additions & 0 deletions meta_replace.sed
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Objects
s/get_status_item/EsiStatusResponse/g
s/get_verify_ok/EsiVerifyResponse/g
12 changes: 12 additions & 0 deletions meta_transformation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# evesso securityDefinitions
echo "Added evesso securityDefinitions"
jq "(.securityDefinitions.evesso) = {\"authorizationUrl\": \"https://login.eveonline.com/v2/oauth/authorize\",\"flow\": \"implicit\",\"scopes\": {}, \"type\": \"oauth2\"}" meta.json > meta_1.json

# evesso verify
echo "Added evesso to verify"
jq "(.paths.\"/verify/\".get.security[0].evesso) = {}" meta_1.json > meta.json

# Clean up
rm meta_1.json
Binary file not shown.
91 changes: 30 additions & 61 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.troja.eve</groupId>
<artifactId>eve-esi</artifactId>
<version>2.4.2-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>EVE-ESI</name>
<description>Java Client for the new Eve Swagger Interface (ESI)</description>
Expand Down Expand Up @@ -31,7 +31,7 @@
<url>https://github.com/burberius</url>
</developer>
<developer>
<id>goldengnu</id>
<id>goldengnu</id>
<name>Niklas Kyster Rasmussen</name>
<email>[email protected]</email>
<url>https://github.com/GoldenGnu</url>
Expand All @@ -40,14 +40,16 @@
</developers>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<swagger-core-version>1.5.21</swagger-core-version>
<jersey-version>2.25.1</jersey-version>
<jackson-version>2.9.8</jackson-version>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<gson-fire-version>1.8.3</gson-fire-version>
<swagger-core-version>1.5.22</swagger-core-version>
<okhttp-version>2.7.5</okhttp-version>
<gson-version>2.8.5</gson-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.12</junit-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
Expand All @@ -56,64 +58,31 @@
<artifactId>swagger-annotations</artifactId>
<version>${swagger-core-version}</version>
</dependency>

<!-- HTTP client: jersey-client -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.security</groupId>
<artifactId>oauth2-client</artifactId>
<version>${jersey-version}</version>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp-version}</version>
</dependency>

<!-- JSON processing: jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-version}</version>
<groupId>com.squareup.okhttp</groupId>
<artifactId>logging-interceptor</artifactId>
<version>${okhttp-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson-version}</version>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version>
<groupId>io.gsonfire</groupId>
<artifactId>gson-fire</artifactId>
<version>${gson-fire-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson-version}</version>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.client</artifactId>
<version>1.0.1</version>
</dependency>

<!-- Base64 encoding that works in both JVM and Android -->
<dependency>
<groupId>com.brsanthu</groupId>
<artifactId>migbase64</artifactId>
<version>2.2</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -147,8 +116,7 @@
<version>2.5.3</version>
<configuration>
<releaseProfiles>production</releaseProfiles>
<goals>jar:test-jar javadoc:jar javadoc:test-jar source:jar
source:test-jar deploy</goals>
<goals>jar:test-jar javadoc:jar javadoc:test-jar source:jar source:test-jar deploy</goals>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -213,6 +181,7 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>local</id>
Expand Down
75 changes: 75 additions & 0 deletions src/main/java/net/troja/eve/esi/ApiCallback.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* EVE Swagger Interface
* An OpenAPI for EVE Online
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

package net.troja.eve.esi;

import java.io.IOException;

import java.util.Map;
import java.util.List;

/**
* Callback for asynchronous API call.
*
* @param <T>
* The return type
*/
public interface ApiCallback<T> {
/**
* This is called when the API call fails.
*
* @param e
* The exception causing the failure
* @param statusCode
* Status code of the response if available, otherwise it would
* be 0
* @param responseHeaders
* Headers of the response if available, otherwise it would be
* null
*/
void onFailure(ApiException e, int statusCode, Map<String, List<String>> responseHeaders);

/**
* This is called when the API call succeeded.
*
* @param result
* The result deserialized from response
* @param statusCode
* Status code of the response
* @param responseHeaders
* Headers of the response
*/
void onSuccess(T result, int statusCode, Map<String, List<String>> responseHeaders);

/**
* This is called when the API upload processing.
*
* @param bytesWritten
* bytes Written
* @param contentLength
* content length of request body
* @param done
* write end
*/
void onUploadProgress(long bytesWritten, long contentLength, boolean done);

/**
* This is called when the API downlond processing.
*
* @param bytesRead
* bytes Read
* @param contentLength
* content lenngth of the response
* @param done
* Read end
*/
void onDownloadProgress(long bytesRead, long contentLength, boolean done);
}
Loading