Skip to content

Commit

Permalink
Use retrofutures and retrolambda to ensure compatibility with JDK 7 t…
Browse files Browse the repository at this point in the history
…o run on older android devices. Add optional token expiration for frontend token generation. Add activity reference creation utility method
  • Loading branch information
Max Klyga committed Jun 5, 2019
1 parent 2dbd3b8 commit 9fa0645
Show file tree
Hide file tree
Showing 71 changed files with 1,558 additions and 1,940 deletions.
1 change: 0 additions & 1 deletion .java-version

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ Add the following dependency to your pom.xml:
<dependency>
<groupId>io.getstream.client</groupId>
<artifactId>stream-java</artifactId>
<version>3.1.5</version>
<version>3.1.7</version>
</dependency>
```

or in your build.gradle:

```gradle
compile 'io.getstream.client:stream-java:3.1.5'
compile 'io.getstream.client:stream-java:3.1.7'
```

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

#### JDK / JVM version requirements

This API Client project requires Java SE 8.
This API Client project requires Java SE 7.

### Full documentation

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

### Building & Testing

Run `gradle wrapper --gradle-version 5.0` to generate gradle wrapper files
Run `gradle wrapper --gradle-version 4.10.3` to generate gradle wrapper files

Run `gradle test` to execute integration tests

Expand Down
25 changes: 13 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
id "me.tatarka.retrolambda" version "3.7.0"
id 'java-library'
id 'eclipse'
id 'idea'
Expand All @@ -9,36 +10,36 @@ plugins {
}

group 'io.getstream.client'
version = '3.1.5'
version = '3.1.7'

dependencies {
testCompile 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testCompile 'org.junit.jupiter:junit-jupiter-params:5.3.1'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
testRuntime 'org.junit.vintage:junit-vintage-engine:5.3.1'
sourceCompatibility = 1.8
targetCompatibility = 1.8

testCompile 'junit:junit:4.12'
testCompile 'com.pholser:junit-quickcheck-core:0.8.1'
testCompile 'com.pholser:junit-quickcheck-generators:0.8.1'
testRuntime 'org.junit.vintage:junit-vintage-engine:5.2.0'

implementation 'com.google.guava:guava:26.0-jre'
implementation 'com.google.guava:guava:20.0'

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

compile 'net.sourceforge.streamsupport:streamsupport:1.7.0'
compile 'net.sourceforge.streamsupport:streamsupport-cfuture:1.7.0'
compile 'com.fasterxml.jackson.core:jackson-core:2.9.6'
compile 'com.fasterxml.jackson.core:jackson-core:2.9.6'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.9.6'
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.6'

compile 'com.auth0:java-jwt:3.4.0'
}

compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
retrolambda {
javaVersion JavaVersion.VERSION_1_7
}

test {
useJUnitPlatform {
includeEngines 'junit-jupiter', 'junit-vintage'
}
testLogging {
exceptionFormat = 'full'
events 'standard_out', 'standard_error', "passed", "skipped", "failed"
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/getstream/client/AggregatedFeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import io.getstream.core.models.Group;
import io.getstream.core.options.*;
import io.getstream.core.utils.DefaultOptions;
import java8.util.concurrent.CompletableFuture;
import java8.util.concurrent.CompletionException;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;

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

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/getstream/client/AnalyticsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import io.getstream.core.models.Engagement;
import io.getstream.core.models.Impression;
import io.getstream.core.utils.Auth.TokenAction;
import java8.util.concurrent.CompletableFuture;

import java.net.URL;
import java.util.concurrent.CompletableFuture;

import static io.getstream.core.utils.Auth.buildAnalyticsRedirectToken;
import static io.getstream.core.utils.Auth.buildAnalyticsToken;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/getstream/client/BatchClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import io.getstream.core.models.FollowRelation;
import io.getstream.core.models.ForeignIDTimePair;
import io.getstream.core.utils.DefaultOptions;
import java8.util.concurrent.CompletableFuture;

import java.util.List;
import java.util.concurrent.CompletableFuture;

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

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/io/getstream/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import io.getstream.core.http.Token;
import io.getstream.core.models.*;
import io.getstream.core.options.RequestOption;
import java8.util.concurrent.CompletableFuture;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
Expand Down Expand Up @@ -179,6 +179,10 @@ public Token frontendToken(String userID) {
return buildFrontendToken(secret, userID);
}

public Token frontendToken(String userID, Date expiresAt) {
return buildFrontendToken(secret, userID, expiresAt);
}

public FlatFeed flatFeed(FeedID id) {
return new FlatFeed(this, id);
}
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/io/getstream/client/CollectionsClient.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package io.getstream.client;

import com.google.common.collect.Iterables;
import com.google.common.collect.Streams;
import io.getstream.core.StreamCollections;
import io.getstream.core.exceptions.StreamException;
import io.getstream.core.http.Token;
import io.getstream.core.models.CollectionData;
import io.getstream.core.utils.Auth.TokenAction;
import io.getstream.core.utils.Streams;
import java8.util.J8Arrays;
import java8.util.concurrent.CompletableFuture;
import java8.util.stream.Collectors;
import java8.util.stream.StreamSupport;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;

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

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

public <T> CompletableFuture<List<T>> selectCustom(Class<T> type, String collection, String... ids) throws StreamException {
return select(collection, ids)
.thenApply(data -> data.stream().map(item -> convert(item, type)).collect(Collectors.toList()));
.thenApply(data -> StreamSupport.stream(data)
.map(item -> convert(item, type))
.collect(Collectors.toList()));
}

public CompletableFuture<List<CollectionData>> select(String collection, Iterable<String> ids) throws StreamException {
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/io/getstream/client/Feed.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.getstream.client;

import com.google.common.collect.Iterables;
import com.google.common.collect.Streams;
import io.getstream.core.exceptions.StreamException;
import io.getstream.core.models.Activity;
import io.getstream.core.models.FeedID;
Expand All @@ -11,13 +10,14 @@
import io.getstream.core.options.Offset;
import io.getstream.core.options.RequestOption;
import io.getstream.core.utils.DefaultOptions;
import io.getstream.core.utils.Streams;
import java8.util.J8Arrays;
import java8.util.concurrent.CompletableFuture;
import java8.util.concurrent.CompletionException;

import java.io.IOException;
import java.lang.reflect.ParameterizedType;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;

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

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

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

final String[] feedIDs = Arrays.stream(feeds)
final String[] feedIDs = J8Arrays.stream(feeds)
.map(id -> id.toString())
.toArray(String[]::new);
final RequestOption[] options = feedIDs.length == 0
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/getstream/client/FileStorageClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import io.getstream.core.exceptions.StreamException;
import io.getstream.core.http.Token;
import io.getstream.core.utils.Auth.TokenAction;
import java8.util.concurrent.CompletableFuture;

import java.io.File;
import java.net.URL;
import java.util.concurrent.CompletableFuture;

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

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/getstream/client/FlatFeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import io.getstream.core.models.FeedID;
import io.getstream.core.options.*;
import io.getstream.core.utils.DefaultOptions;
import java8.util.concurrent.CompletableFuture;
import java8.util.concurrent.CompletionException;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;

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

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/getstream/client/ImageStorageClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import io.getstream.core.options.Crop;
import io.getstream.core.options.Resize;
import io.getstream.core.utils.Auth.TokenAction;
import java8.util.concurrent.CompletableFuture;

import java.io.File;
import java.net.URL;
import java.util.concurrent.CompletableFuture;

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

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/getstream/client/NotificationFeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import io.getstream.core.models.NotificationGroup;
import io.getstream.core.options.*;
import io.getstream.core.utils.DefaultOptions;
import java8.util.concurrent.CompletableFuture;
import java8.util.concurrent.CompletionException;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import io.getstream.core.exceptions.StreamException;
import io.getstream.core.http.Token;
import io.getstream.core.utils.Auth.TokenAction;
import java8.util.concurrent.CompletableFuture;

import java.util.Map;
import java.util.concurrent.CompletableFuture;

import static io.getstream.core.utils.Auth.buildPersonalizationToken;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/getstream/client/ReactionsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import io.getstream.core.options.Limit;
import io.getstream.core.utils.Auth.TokenAction;
import io.getstream.core.utils.DefaultOptions;
import java8.util.concurrent.CompletableFuture;

import java.util.List;
import java.util.concurrent.CompletableFuture;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/getstream/client/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import io.getstream.core.exceptions.StreamException;
import io.getstream.core.models.Data;
import io.getstream.core.models.ProfileData;
import java8.util.concurrent.CompletableFuture;
import java8.util.concurrent.CompletionException;

import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/getstream/cloud/CloudAggregatedFeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import io.getstream.core.models.Group;
import io.getstream.core.options.*;
import io.getstream.core.utils.DefaultOptions;
import java8.util.concurrent.CompletableFuture;
import java8.util.concurrent.CompletionException;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;

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

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/io/getstream/cloud/CloudAnalyticsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import io.getstream.core.http.Token;
import io.getstream.core.models.Engagement;
import io.getstream.core.models.Impression;

import java.util.concurrent.CompletableFuture;
import java8.util.concurrent.CompletableFuture;

public final class CloudAnalyticsClient {
private final Token token;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/getstream/cloud/CloudClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import io.getstream.core.models.FeedID;
import io.getstream.core.models.OGData;
import io.getstream.core.options.RequestOption;
import java8.util.concurrent.CompletableFuture;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.CompletableFuture;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/io/getstream/cloud/CloudCollectionsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import io.getstream.core.exceptions.StreamException;
import io.getstream.core.http.Token;
import io.getstream.core.models.CollectionData;

import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import java8.util.concurrent.CompletableFuture;

import static io.getstream.core.utils.Serialization.convert;

Expand Down
Loading

0 comments on commit 9fa0645

Please sign in to comment.