Skip to content

Commit 9fa0645

Browse files
author
Max Klyga
committed
Use retrofutures and retrolambda to ensure compatibility with JDK 7 to run on older android devices. Add optional token expiration for frontend token generation. Add activity reference creation utility method
1 parent 2dbd3b8 commit 9fa0645

File tree

71 files changed

+1558
-1940
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1558
-1940
lines changed

.java-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ Add the following dependency to your pom.xml:
1212
<dependency>
1313
<groupId>io.getstream.client</groupId>
1414
<artifactId>stream-java</artifactId>
15-
<version>3.1.5</version>
15+
<version>3.1.7</version>
1616
</dependency>
1717
```
1818

1919
or in your build.gradle:
2020

2121
```gradle
22-
compile 'io.getstream.client:stream-java:3.1.5'
22+
compile 'io.getstream.client:stream-java:3.1.7'
2323
```
2424

2525
In case you want to download the artifact and put it manually into your project,
@@ -29,7 +29,7 @@ Snapshots of the development version are available in [Sonatype](https://oss.son
2929

3030
#### JDK / JVM version requirements
3131

32-
This API Client project requires Java SE 8.
32+
This API Client project requires Java SE 7.
3333

3434
### Full documentation
3535

@@ -43,7 +43,7 @@ Javadocs are available [here](https://getstream.github.io/stream-java/).
4343

4444
### Building & Testing
4545

46-
Run `gradle wrapper --gradle-version 5.0` to generate gradle wrapper files
46+
Run `gradle wrapper --gradle-version 4.10.3` to generate gradle wrapper files
4747

4848
Run `gradle test` to execute integration tests
4949

build.gradle

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
id "me.tatarka.retrolambda" version "3.7.0"
23
id 'java-library'
34
id 'eclipse'
45
id 'idea'
@@ -9,36 +10,36 @@ plugins {
910
}
1011

1112
group 'io.getstream.client'
12-
version = '3.1.5'
13+
version = '3.1.7'
1314

1415
dependencies {
15-
testCompile 'org.junit.jupiter:junit-jupiter-api:5.3.1'
16-
testCompile 'org.junit.jupiter:junit-jupiter-params:5.3.1'
17-
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
18-
testRuntime 'org.junit.vintage:junit-vintage-engine:5.3.1'
16+
sourceCompatibility = 1.8
17+
targetCompatibility = 1.8
18+
19+
testCompile 'junit:junit:4.12'
1920
testCompile 'com.pholser:junit-quickcheck-core:0.8.1'
2021
testCompile 'com.pholser:junit-quickcheck-generators:0.8.1'
22+
testRuntime 'org.junit.vintage:junit-vintage-engine:5.2.0'
2123

22-
implementation 'com.google.guava:guava:26.0-jre'
24+
implementation 'com.google.guava:guava:20.0'
2325

2426
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
2527

28+
compile 'net.sourceforge.streamsupport:streamsupport:1.7.0'
29+
compile 'net.sourceforge.streamsupport:streamsupport-cfuture:1.7.0'
30+
compile 'com.fasterxml.jackson.core:jackson-core:2.9.6'
2631
compile 'com.fasterxml.jackson.core:jackson-core:2.9.6'
2732
compile 'com.fasterxml.jackson.core:jackson-annotations:2.9.6'
2833
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.6'
2934

3035
compile 'com.auth0:java-jwt:3.4.0'
3136
}
3237

33-
compileJava {
34-
sourceCompatibility = 1.8
35-
targetCompatibility = 1.8
38+
retrolambda {
39+
javaVersion JavaVersion.VERSION_1_7
3640
}
3741

3842
test {
39-
useJUnitPlatform {
40-
includeEngines 'junit-jupiter', 'junit-vintage'
41-
}
4243
testLogging {
4344
exceptionFormat = 'full'
4445
events 'standard_out', 'standard_error', "passed", "skipped", "failed"

src/main/java/io/getstream/client/AggregatedFeed.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
import io.getstream.core.models.Group;
88
import io.getstream.core.options.*;
99
import io.getstream.core.utils.DefaultOptions;
10+
import java8.util.concurrent.CompletableFuture;
11+
import java8.util.concurrent.CompletionException;
1012

1113
import java.io.IOException;
1214
import java.util.List;
13-
import java.util.concurrent.CompletableFuture;
14-
import java.util.concurrent.CompletionException;
1515

1616
import static io.getstream.core.utils.Serialization.deserializeContainer;
1717

src/main/java/io/getstream/client/AnalyticsClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import io.getstream.core.models.Engagement;
88
import io.getstream.core.models.Impression;
99
import io.getstream.core.utils.Auth.TokenAction;
10+
import java8.util.concurrent.CompletableFuture;
1011

1112
import java.net.URL;
12-
import java.util.concurrent.CompletableFuture;
1313

1414
import static io.getstream.core.utils.Auth.buildAnalyticsRedirectToken;
1515
import static io.getstream.core.utils.Auth.buildAnalyticsToken;

src/main/java/io/getstream/client/BatchClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import io.getstream.core.models.FollowRelation;
1010
import io.getstream.core.models.ForeignIDTimePair;
1111
import io.getstream.core.utils.DefaultOptions;
12+
import java8.util.concurrent.CompletableFuture;
1213

1314
import java.util.List;
14-
import java.util.concurrent.CompletableFuture;
1515

1616
import static io.getstream.core.utils.Auth.*;
1717

src/main/java/io/getstream/client/Client.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
import io.getstream.core.http.Token;
1111
import io.getstream.core.models.*;
1212
import io.getstream.core.options.RequestOption;
13+
import java8.util.concurrent.CompletableFuture;
1314

1415
import java.net.MalformedURLException;
1516
import java.net.URL;
1617
import java.util.Date;
1718
import java.util.List;
1819
import java.util.Map;
19-
import java.util.concurrent.CompletableFuture;
2020

2121
import static com.google.common.base.Preconditions.checkArgument;
2222
import static com.google.common.base.Preconditions.checkNotNull;
@@ -179,6 +179,10 @@ public Token frontendToken(String userID) {
179179
return buildFrontendToken(secret, userID);
180180
}
181181

182+
public Token frontendToken(String userID, Date expiresAt) {
183+
return buildFrontendToken(secret, userID, expiresAt);
184+
}
185+
182186
public FlatFeed flatFeed(FeedID id) {
183187
return new FlatFeed(this, id);
184188
}

src/main/java/io/getstream/client/CollectionsClient.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
package io.getstream.client;
22

33
import com.google.common.collect.Iterables;
4-
import com.google.common.collect.Streams;
54
import io.getstream.core.StreamCollections;
65
import io.getstream.core.exceptions.StreamException;
76
import io.getstream.core.http.Token;
87
import io.getstream.core.models.CollectionData;
98
import io.getstream.core.utils.Auth.TokenAction;
9+
import io.getstream.core.utils.Streams;
10+
import java8.util.J8Arrays;
11+
import java8.util.concurrent.CompletableFuture;
12+
import java8.util.stream.Collectors;
13+
import java8.util.stream.StreamSupport;
1014

11-
import java.util.Arrays;
1215
import java.util.List;
13-
import java.util.concurrent.CompletableFuture;
14-
import java.util.stream.Collectors;
1516

1617
import static io.getstream.core.utils.Auth.buildCollectionsToken;
1718
import static io.getstream.core.utils.Serialization.convert;
@@ -69,7 +70,7 @@ public <T> CompletableFuture<Void> upsertCustom(String collection, Iterable<T> i
6970
}
7071

7172
public <T> CompletableFuture<Void> upsertCustom(String collection, T... items) throws StreamException {
72-
final CollectionData[] custom = Arrays.stream(items)
73+
final CollectionData[] custom = J8Arrays.stream(items)
7374
.map(item -> CollectionData.buildFrom(item))
7475
.toArray(CollectionData[]::new);
7576
return upsert(collection, custom);
@@ -99,7 +100,9 @@ public <T> CompletableFuture<List<T>> selectCustom(Class<T> type, String collect
99100

100101
public <T> CompletableFuture<List<T>> selectCustom(Class<T> type, String collection, String... ids) throws StreamException {
101102
return select(collection, ids)
102-
.thenApply(data -> data.stream().map(item -> convert(item, type)).collect(Collectors.toList()));
103+
.thenApply(data -> StreamSupport.stream(data)
104+
.map(item -> convert(item, type))
105+
.collect(Collectors.toList()));
103106
}
104107

105108
public CompletableFuture<List<CollectionData>> select(String collection, Iterable<String> ids) throws StreamException {

src/main/java/io/getstream/client/Feed.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.getstream.client;
22

33
import com.google.common.collect.Iterables;
4-
import com.google.common.collect.Streams;
54
import io.getstream.core.exceptions.StreamException;
65
import io.getstream.core.models.Activity;
76
import io.getstream.core.models.FeedID;
@@ -11,13 +10,14 @@
1110
import io.getstream.core.options.Offset;
1211
import io.getstream.core.options.RequestOption;
1312
import io.getstream.core.utils.DefaultOptions;
13+
import io.getstream.core.utils.Streams;
14+
import java8.util.J8Arrays;
15+
import java8.util.concurrent.CompletableFuture;
16+
import java8.util.concurrent.CompletionException;
1417

1518
import java.io.IOException;
1619
import java.lang.reflect.ParameterizedType;
17-
import java.util.Arrays;
1820
import java.util.List;
19-
import java.util.concurrent.CompletableFuture;
20-
import java.util.concurrent.CompletionException;
2121

2222
import static com.google.common.base.Preconditions.checkArgument;
2323
import static com.google.common.base.Preconditions.checkNotNull;
@@ -108,7 +108,7 @@ public final CompletableFuture<List<Activity>> addActivities(Activity... activit
108108
}
109109

110110
public final <T> CompletableFuture<List<T>> addCustomActivities(T... activities) throws StreamException {
111-
final Activity[] custom = Arrays.stream(activities)
111+
final Activity[] custom = J8Arrays.stream(activities)
112112
.map(activity -> Activity.builder().fromCustomActivity(activity).build())
113113
.toArray(Activity[]::new);
114114
return getClient()
@@ -196,7 +196,7 @@ public final CompletableFuture<List<FollowRelation>> getFollowers(Limit limit, O
196196
public final CompletableFuture<List<FollowRelation>> getFollowers(Limit limit, Offset offset, FeedID... feeds) throws StreamException {
197197
checkNotNull(feeds, "No feed ids to filter on");
198198

199-
final String[] feedIDs = Arrays.stream(feeds)
199+
final String[] feedIDs = J8Arrays.stream(feeds)
200200
.map(id -> id.toString())
201201
.toArray(String[]::new);
202202
final RequestOption[] options = feedIDs.length == 0
@@ -244,7 +244,7 @@ public final CompletableFuture<List<FollowRelation>> getFollowed(Limit limit, Of
244244
public final CompletableFuture<List<FollowRelation>> getFollowed(Limit limit, Offset offset, FeedID... feeds) throws StreamException {
245245
checkNotNull(feeds, "No feed ids to filter on");
246246

247-
final String[] feedIDs = Arrays.stream(feeds)
247+
final String[] feedIDs = J8Arrays.stream(feeds)
248248
.map(id -> id.toString())
249249
.toArray(String[]::new);
250250
final RequestOption[] options = feedIDs.length == 0

src/main/java/io/getstream/client/FileStorageClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import io.getstream.core.exceptions.StreamException;
55
import io.getstream.core.http.Token;
66
import io.getstream.core.utils.Auth.TokenAction;
7+
import java8.util.concurrent.CompletableFuture;
78

89
import java.io.File;
910
import java.net.URL;
10-
import java.util.concurrent.CompletableFuture;
1111

1212
import static io.getstream.core.utils.Auth.buildFilesToken;
1313

0 commit comments

Comments
 (0)