Skip to content

Commit

Permalink
2.1.0 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Karl Rieb committed Jul 30, 2016
1 parent 81804e8 commit af7a43e
Show file tree
Hide file tree
Showing 168 changed files with 7,073 additions and 6,414 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ intellij/
.idea/
*.iml
gradle.properties
local.properties

# Output file when rendering ReadMe.md locally.
/ReadMe.html

# editor temp files
*~
*~

# pyc files from generator
*.pyc
27 changes: 27 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
2.1.0 (2016-07-29)
---------------------------------------------
- Update to latest API specs:
- Files
- Add uploadSessionFinishBatch(..) endpoint for batch uploads.
- Sharing:
- Add changeFileMemberAccess(..) for changing a member's access to a shared file.
- Add INVITE_VIEWER_NO_COMMENT and SHARE_LINK to FolderAction.
- Add MemberAction.MAKE_VIEWER_NO_COMMENT.
- Add preview URL to SharedFolderMetadata.
- Add parent folder access information to MemberAccessLevelResult.
- Add AddFolderMemberError.TOO_MANY_INVITEES.
- Add AddMemberSelectorError.AUTOMATIC_GROUP.
- Add MountFolderError.INSUFFICIENT_QUOTA.
- Team:
- Add TeamMemberStatus.Tag.REMOVED.
- Add ability to update group management type for a group.
- Add ability to include removed members when listing members of a team.
- Add membersRecover(..) endpoint for recovering team members.
- Fix OkHttpRequestor/OkHttp3Requestor to support interceptors that consume request bodies, like Stetho.
- Fix does not apply to streaming uploads.
- Fix OkHttpRequestor/OkHttp3Requestor to properly handle streaming uploads.
- The requestors no longer buffer entire request body in memory for streams.
- Add configureRequest(..) method for simpler subclassing of OkHttpRequestor and OkHttp3Requestor.
- Fix BadRequest error when adding custom state to a DbxWebAuth.Request object.
- Remove final modifier from DbxClientV2 and DbxTeamClientV2 class declarations for easier mocking in tests.

2.0.6 (2016-06-20)
---------------------------------------------
- Update to latest API specs:
Expand Down
13 changes: 7 additions & 6 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A Java library to access [Dropbox's HTTP-based Core API v2](https://www.dropbox.

License: [MIT](License.txt)

[Javadoc.](https://dropbox.github.io/dropbox-sdk-java/api-docs/v2.0.x/)
[Javadoc.](https://dropbox.github.io/dropbox-sdk-java/api-docs/v2.1.x/)

## Setup

Expand All @@ -14,7 +14,7 @@ If you're using Maven, then edit your project's "pom.xml" and add this to the `<
<dependency>
<groupId>com.dropbox.core</groupId>
<artifactId>dropbox-core-sdk</artifactId>
<version>2.0.6</version>
<version>2.1.0</version>
</dependency>
```

Expand All @@ -23,11 +23,11 @@ If you are using Gradle, then edit your project's "build.gradle" and add this to
```groovy
dependencies {
// ...
compile 'com.dropbox.core:dropbox-core-sdk:2.0.6'
compile 'com.dropbox.core:dropbox-core-sdk:2.1.0'
}
```

You can also download the Java SDK JAR and and its dependencies directly from the [latest release page](https://github.com/dropbox/dropbox-sdk-java/releases/latest).
You can also download the Java SDK JAR and and its required dependencies directly from the [latest release page](https://github.com/dropbox/dropbox-sdk-java/releases/latest). Note that the distribution artifacts on the releases pages do not contain optional dependencies.

## Get a Dropbox API key

Expand All @@ -52,7 +52,7 @@ Before your app can access a Dropbox user's files, the user must authorize your
* Example for an Android app: [Android example](examples/android/src/main/java/com/dropbox/core/examples/android/UserActivity.java)
* Example for a command-line tool: [Command-Line Authorization example](examples/authorize/src/main/java/com/dropbox/core/examples/authorize/Main.java)

Once you have an access token, create a [`DbxClientV2`](https://dropbox.github.io/dropbox-sdk-java/api-docs/v2.0.x/com/dropbox/core/v2/DbxClientV2.html) and start making API calls.
Once you have an access token, create a [`DbxClientV2`](https://dropbox.github.io/dropbox-sdk-java/api-docs/v2.1.x/com/dropbox/core/v2/DbxClientV2.html) and start making API calls.

You only need to perform the authorization process once per user. Once you have an access token for a user, save it somewhere persistent, like in a database. The next time that user visits your app's, you can skip the authorization process and go straight to creating a `DbxClientV2` and making API calls.

Expand Down Expand Up @@ -158,9 +158,10 @@ Another workaround is to tell your OSGi container to provide that requirement: [

### Does this SDK require any special ProGuard rules for shrink optimizations?

Versions 2.0.0-2.0.3 of this SDK require specific ProGuard rules to work with shrinking enabled. However, since version **2.0.4**, the SDK no longer needs special ProGuard directives. However, you may want to consider adding "-dontwarn" directives for unused optional dependencies:
Versions 2.0.0-2.0.3 of this SDK require SDK-specific ProGuard rules when shrinking is enabled. However, since version **2.0.4**, the only ProGuard rules necessary are for the SDK's required and optional dependencies. If you encounter ProGuard warnings, consider adding the following "-dontwarn" directives to your ProGuard configuration file:

```
-dontwarn okio.**
-dontwarn okhttp3.**
-dontwarn com.squareup.okhttp.**
-dontwarn com.google.appengine.**
Expand Down
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ dependencies {
testCompile 'com.google.appengine:appengine-testing:1.9.38'
testCompile 'com.squareup.okhttp:okhttp:2.7.5'
testCompile 'com.squareup.okhttp3:okhttp:3.3.1'
testCompile 'com.google.guava:guava:19.0'
}

processResources {
Expand All @@ -109,8 +110,7 @@ test {
useTestNG()

// TestNG specific options
options.parallel 'classesAndMethods'
options.preserveOrder true
options.parallel 'methods'
options.threadCount 4

// exclude integration tests
Expand Down Expand Up @@ -153,6 +153,8 @@ task integrationTest(type: Test) {
useTestNG()

// TestNG specific options
options.parallel 'classes'
options.threadCount 4
options.preserveOrder true

// only select integration tests (similar to maven-failsafe-plugin rules)
Expand Down
1 change: 0 additions & 1 deletion examples/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.fasterxml.jackson.core:jackson-core:2.7.4'
// picasso 2.5.2 doesn't have OkHttp3 support (although it exists
// on master). Must use OkHttp v2 and v3 until new picasso release
compile 'com.squareup.picasso:picasso:2.5.2'
Expand Down
4 changes: 3 additions & 1 deletion examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ subprojects {
standardInput = System.in
classpath = sourceSets.main.runtimeClasspath
main = "com.dropbox.core.examples.${project.name.replace('-','_')}.Main"
ignoreExitValue true

// convenience for not having to always specify the auth file
def useAuthInfoFileProp = project.properties.get('useAuthInfoFileProp', 'false') == 'true'
if (useAuthInfoFileProp && project.hasProperty('com.dropbox.test.authInfoFile')) {
args project.property('com.dropbox.test.authInfoFile')
}

def failOnError = project.properties.get('failOnError', 'false') == 'true'
ignoreExitValue !failOnError

def argi = 0
while (true) {
def prop = "arg${argi}"
Expand Down
19 changes: 16 additions & 3 deletions examples/run
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,23 @@ if [ $# -eq 0 ]; then
fi

declare -a project_properties
if [ "${1}" == '--use-auth-prop' ] ; then
project_properties+=("-PuseAuthInfoFileProp=true")
while [[ $# -gt 0 ]]; do
case "${1}" in
--use-auth-prop)
project_properties+=("-PuseAuthInfoFileProp=true")
;;
--fail-on-error)
project_properties+=("-PfailOnError=true")
;;
--*)
die "unrecognized argument: ${1}"
;;
*)
break
;;
esac
shift
fi
done

example_name="$1" ; shift
example_name="$(echo "$example_name" | sed 's|/*$||')"
Expand Down
4 changes: 0 additions & 4 deletions settings.gradle

This file was deleted.

13 changes: 13 additions & 0 deletions src/main/java/com/dropbox/core/DbxAuthFinish.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ public String getUserId() {
return urlState;
}

/**
* State is not returned from /oauth2/token call, so we must
* append it after the JSON parsing.
*
* @param urlState Custom state passed into /oauth2/authorize
*/
DbxAuthFinish withUrlState(/*@Nullable*/ String urlState) {
if (this.urlState != null) {
throw new IllegalStateException("Already have URL state.");
}
return new DbxAuthFinish(accessToken, userId, urlState);
}

/**
* For JSON parsing.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/dropbox/core/DbxHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public final class DbxHost {
* and "www.dropbox.com"
*/
public static final DbxHost DEFAULT = new DbxHost(
"api.dropbox.com",
"api-content.dropbox.com",
"api.dropboxapi.com",
"content.dropboxapi.com",
"www.dropbox.com",
"api-notify.dropbox.com"
"notify.dropboxapi.com"
);

private final String api;
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/dropbox/core/DbxRequestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;

import com.dropbox.core.stone.StoneSerializer;
import com.dropbox.core.http.HttpRequestor;
Expand All @@ -27,6 +28,7 @@
/*>>> import checkers.nullness.quals.Nullable; */

public final class DbxRequestUtil {
private static final Random RAND = new Random();

public static String encodeUrlParam(String s) {
try {
Expand Down Expand Up @@ -229,7 +231,7 @@ public static HttpRequestor.Response startPostRaw(DbxRequestConfig requestConfig
try {
HttpRequestor.Uploader uploader = requestConfig.getHttpRequestor().startPost(uri, headers);
try {
uploader.getBody().write(body);
uploader.upload(body);
return uploader.finish();
} finally {
uploader.close();
Expand Down Expand Up @@ -442,6 +444,10 @@ public static <T, E extends Throwable> T runAndRetry(int maxRetries, RequestMake
throw thrown;
}

// add a random jitter to the backoff to avoid stampeding herd. This is especially
// useful for ServerExceptions, where backoff is 0.
backoff += RAND.nextInt(1000);

if (backoff > 0L) {
try {
Thread.sleep(backoff);
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/com/dropbox/core/DbxUploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ protected DbxUploader(HttpRequestor.Uploader httpUploader, StoneSerializer<R> re
public R uploadAndFinish(InputStream in) throws X, DbxException, IOException {
try {
try {
IOUtil.copyStreamToStream(in, getOutputStream());
} catch (IOUtil.ReadException ex) {
// read exceptions should be IOException
throw ex.getCause();
httpUploader.upload(in);
} catch (IOException ex) {
// write exceptions and everything else is a Network I/O problem
throw new NetworkIOException(ex);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/dropbox/core/DbxWebAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ private DbxAuthFinish finish(String code) throws DbxException {
return finish(code, null, null);
}

private DbxAuthFinish finish(String code, String redirectUri, String state) throws DbxException {
private DbxAuthFinish finish(String code, String redirectUri, final String state) throws DbxException {
if (code == null) throw new NullPointerException("code");

Map<String, String> params = new HashMap<String, String>();
Expand All @@ -379,7 +379,6 @@ private DbxAuthFinish finish(String code, String redirectUri, String state) thro

if (redirectUri != null) {
params.put("redirect_uri", redirectUri);
params.put("state", state);
}

List<HttpRequestor.Header> headers = new ArrayList<HttpRequestor.Header>();
Expand All @@ -398,7 +397,8 @@ public DbxAuthFinish handle(HttpRequestor.Response response) throws DbxException
if (response.getStatusCode() != 200) {
throw DbxRequestUtil.unexpectedStatus(response);
}
return DbxRequestUtil.readJsonFromResponse(DbxAuthFinish.Reader, response);
return DbxRequestUtil.readJsonFromResponse(DbxAuthFinish.Reader, response)
.withUrlState(state);
}
}
);
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/com/dropbox/core/http/GoogleAppEngineRequestor.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -75,13 +76,13 @@ public Response doGet(String url, Iterable<Header> headers) throws IOException {
@Override
public Uploader startPost(String url, Iterable<Header> headers) throws IOException {
HTTPRequest request = newRequest(url, HTTPMethod.POST, headers);
return new Uploader(service, request, new ByteArrayOutputStream());
return new FetchServiceUploader(service, request, new ByteArrayOutputStream());
}

@Override
public Uploader startPut(String url, Iterable<Header> headers) throws IOException {
HTTPRequest request = newRequest(url, HTTPMethod.POST, headers);
return new Uploader(service, request, new ByteArrayOutputStream());
return new FetchServiceUploader(service, request, new ByteArrayOutputStream());
}

private HTTPRequest newRequest(String url, HTTPMethod method, Iterable<Header> headers) throws IOException {
Expand Down Expand Up @@ -123,19 +124,23 @@ private static Response toRequestorResponse(HTTPResponse response) {
headers);
}

private static class Uploader extends HttpRequestor.Uploader {
private static class FetchServiceUploader extends Uploader {
private final URLFetchService service;
private final ByteArrayOutputStream body;

private HTTPRequest request;

public Uploader(URLFetchService service, HTTPRequest request, ByteArrayOutputStream body) {
super(body);
public FetchServiceUploader(URLFetchService service, HTTPRequest request, ByteArrayOutputStream body) {
this.service = service;
this.request = request;
this.body = body;
}

@Override
public OutputStream getBody() {
return body;
}

@Override
public void close() {
if (request != null) {
Expand Down
Loading

0 comments on commit af7a43e

Please sign in to comment.