Skip to content

Commit 08842cf

Browse files
Ian OrtonKannan Goundan
authored andcommitted
Put v1 and v2 classes in separate packages.
Should not have been added
1 parent 5687ec5 commit 08842cf

File tree

31 files changed

+351
-202
lines changed

31 files changed

+351
-202
lines changed

ReadMe.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ Before your app can access a Dropbox user's files, the user must authorize your
4747
* Authorization example for a simple web app: [Web File Browser example](examples/web-file-browser/src/com/dropbox/core/examples/web_file_browser/DropboxAuth.java)
4848
* Authorization example for a command-line tool: [Command-Line Authorization example](examples/authorize/src/com/dropbox/core/examples/authorize/Main.java)
4949

50-
Once you have an access token, create a [`DbxClient`](http://dropbox.github.io/dropbox-sdk-java/api-docs/v1.8.x/com/dropbox/core/DbxClient.html) and start making API calls.
50+
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.
5151

52-
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 `DbxClient` and making API calls.
52+
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.
5353

5454
## Running the examples
5555

examples/account-info/src/com/dropbox/core/examples/account_info/Main.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import com.dropbox.core.*;
44
import com.dropbox.core.json.JsonReader;
5+
import com.dropbox.core.v1.DbxAccountInfo;
6+
import com.dropbox.core.v1.DbxClientV1;
57

68
import java.io.IOException;
79
import java.util.Locale;
@@ -49,10 +51,10 @@ public static void main(String[] args)
4951
System.exit(1); return;
5052
}
5153

52-
// Create a DbxClient, which is what you use to make API calls.
54+
// Create a DbxClientV1, which is what you use to make API calls.
5355
String userLocale = Locale.getDefault().toString();
5456
DbxRequestConfig requestConfig = new DbxRequestConfig("examples-account-info", userLocale);
55-
DbxClient dbxClient = new DbxClient(requestConfig, authInfo.accessToken, authInfo.host);
57+
DbxClientV1 dbxClient = new DbxClientV1(requestConfig, authInfo.accessToken, authInfo.host);
5658

5759
// Make the /account/info API call.
5860
DbxAccountInfo dbxAccountInfo;

examples/upload-file/src/com/dropbox/core/examples/upload_file/Main.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import com.dropbox.core.*;
44
import com.dropbox.core.json.JsonReader;
55
import com.dropbox.core.util.IOUtil;
6+
import com.dropbox.core.v1.DbxClientV1;
7+
import com.dropbox.core.v1.DbxEntry;
8+
import com.dropbox.core.v1.DbxWriteMode;
69

710
import java.io.FileInputStream;
811
import java.io.IOException;
@@ -71,10 +74,10 @@ private static int _main(String[] args)
7174
return 1;
7275
}
7376

74-
// Create a DbxClient, which is what you use to make API calls.
77+
// Create a DbxClientV1, which is what you use to make API calls.
7578
String userLocale = Locale.getDefault().toString();
7679
DbxRequestConfig requestConfig = new DbxRequestConfig("examples-upload-file", userLocale);
77-
DbxClient dbxClient = new DbxClient(requestConfig, authInfo.accessToken, authInfo.host);
80+
DbxClientV1 dbxClient = new DbxClientV1(requestConfig, authInfo.accessToken, authInfo.host);
7881

7982
// Make the API call to upload the file.
8083
DbxEntry.File metadata;

examples/web-file-browser/src/com/dropbox/core/examples/web_file_browser/DropboxBrowse.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
import static com.dropbox.core.util.StringUtil.jq;
44
import static com.dropbox.core.util.StringUtil.UTF8;
55

6-
import com.dropbox.core.*;
6+
import com.dropbox.core.DbxException;
7+
import com.dropbox.core.DbxRequestUtil;
8+
import com.dropbox.core.v1.DbxClientV1;
9+
import com.dropbox.core.v1.DbxEntry;
10+
import com.dropbox.core.DbxPath;
11+
import com.dropbox.core.v1.DbxWriteMode;
712

813
import javax.servlet.ServletException;
914
import javax.servlet.http.HttpServletRequest;
@@ -28,15 +33,15 @@ public DropboxBrowse(Common common)
2833
this.common = common;
2934
}
3035

31-
private DbxClient requireDbxClient(HttpServletRequest request, HttpServletResponse response, User user)
36+
private DbxClientV1 requireDbxClient(HttpServletRequest request, HttpServletResponse response, User user)
3237
throws IOException, ServletException
3338
{
3439
if (user.dropboxAccessToken == null) {
3540
common.pageSoftError(response, "This page requires a user whose has linked to their Dropbox account. Current user hasn't linked us to their Dropbox account.");
3641
return null;
3742
}
3843

39-
return new DbxClient(common.getRequestConfig(request),
44+
return new DbxClientV1(common.getRequestConfig(request),
4045
user.dropboxAccessToken,
4146
common.dbxAppInfo.host);
4247
}
@@ -57,7 +62,7 @@ public void doBrowse(HttpServletRequest request, HttpServletResponse response)
5762
return;
5863
}
5964

60-
DbxClient dbxClient = requireDbxClient(request, response, user);
65+
DbxClientV1 dbxClient = requireDbxClient(request, response, user);
6166
if (dbxClient == null) return;
6267

6368
// Make sure the path starts with '/'. There are probably other checks we can perform...
@@ -144,7 +149,7 @@ public void doUpload(HttpServletRequest request, HttpServletResponse response)
144149
User user = common.requireLoggedInUser(request, response);
145150
if (user == null) return;
146151

147-
DbxClient dbxClient = requireDbxClient(request, response, user);
152+
DbxClientV1 dbxClient = requireDbxClient(request, response, user);
148153
if (dbxClient == null) return;
149154

150155
try {

generator/java.babelg.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def generate_namespace_wrapper(self, namespace, package_relpath, package_name):
277277
out('import com.fasterxml.jackson.core.JsonParser;')
278278
out('import com.fasterxml.jackson.core.JsonToken;')
279279
out('import com.dropbox.core.DbxApiError;')
280-
out('import com.dropbox.core.DbxClient;')
280+
out('import com.dropbox.core.v2.DbxRawClientV2;')
281281
out('import com.dropbox.core.DbxException;')
282282
out('import com.dropbox.core.DbxRequestUtil;')
283283
out('import com.dropbox.core.http.HttpRequestor;')
@@ -304,9 +304,9 @@ def generate_namespace_wrapper(self, namespace, package_relpath, package_name):
304304
with self.block('public final class %s' % class_name):
305305
out('// namespace %s' % namespace.name)
306306
out('')
307-
out('private final DbxClient client;')
307+
out('private final DbxRawClientV2 client;')
308308
out('')
309-
with self.block('public %s(DbxClient client)' % class_name):
309+
with self.block('%s(DbxRawClientV2 client)' % class_name):
310310
out('this.client = client;')
311311
for data_type in namespace.linearize_data_types():
312312
out('')
@@ -412,7 +412,7 @@ def generate_packed_method(self, namespace, route):
412412
'arg' if arg_name != 'void' else 'null',
413413
arg_name + '._writer' if arg_name != 'void' else 'null',
414414
uploader_maker,
415-
], before='return (%s) DbxRequestUtil.uploadStyle' % uploader, after=';')
415+
], before='return (%s) DbxRawClientV2.uploadStyle' % uploader, after=';')
416416
else:
417417
ret = '' if is_void_type(route.response_data_type) else 'return '
418418
self.generate_multiline_list([
@@ -424,7 +424,7 @@ def generate_packed_method(self, namespace, route):
424424
arg_name + '._writer' if arg_name != 'void' else 'null',
425425
'%s' % result_reader,
426426
'%s' % error_reader,
427-
], before='%sDbxRequestUtil.%sStyle' % (ret, style), after=';')
427+
], before='%sDbxRawClientV2.%sStyle' % (ret, style), after=';')
428428
if style != 'upload':
429429
with self.block('catch (DbxRequestUtil.ErrorWrapper ew)'):
430430
if error_name == 'void':

run-babel-codegen

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ PYTHONPATH="$babel_dir" python3 -m babelapi.cli \
5050
"$spec_dir"/*.babel \
5151
"$gen_dir"\
5252
--\
53-
--package com.dropbox.core
53+
--package com.dropbox.core.v2
5454

5555
mv "$gen_dir/stamp.tmp" "$gen_dir/stamp" # Only move to "stamp" when codegen succeeds.

run-tests

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ Usage: $0 <path-to-auth-file> [ <test-selector> ] [ --okhttp ]
1515
1616
<test-selector> [optional]: If omitted, all the tests are run. If
1717
provided, only the specified tests are run. Example values:
18-
- "DbxClientTest"
19-
- "DbxClientTest,StringUtilTest"
20-
- "DbxClientTest#testMoveFolder"
21-
- "DbxClientTest#testMove*"
22-
- "DbxClientTest#testMoveFolder+testMoveEmptyFolder"
18+
- "DbxClientV1Test"
19+
- "DbxClientV1Test,StringUtilTest"
20+
- "DbxClientV1Test#testMoveFolder"
21+
- "DbxClientV1Test#testMove*"
22+
- "DbxClientV1Test#testMoveFolder+testMoveEmptyFolder"
2323
2424
For the full specification, see:
2525
http://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html

src/com/dropbox/core/DbxAuthFinish.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.io.IOException;
1313

1414
/*>>> import checkers.nullness.quals.Nullable; */
15+
/*>>> import com.dropbox.core.v2.DbxClientV2; */
1516

1617
/**
1718
* When you successfully complete the authorization process, the Dropbox server returns
@@ -23,7 +24,7 @@ public final class DbxAuthFinish implements java.io.Serializable
2324

2425
/**
2526
* An <em>access token</em> that can be used to make Dropbox API calls.
26-
* Pass this in to the {@link DbxClient} constructor.
27+
* Pass this in to the {@link com.dropbox.core.v2.DbxClientV2} constructor.
2728
*/
2829
public final String accessToken;
2930

src/com/dropbox/core/DbxDownloader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class DbxDownloader<R> {
88
public final R result;
99
public final InputStream body;
1010

11-
DbxDownloader(R result, InputStream body) {
11+
public DbxDownloader(R result, InputStream body) {
1212
this.result = result;
1313
this.body = body;
1414
}

src/com/dropbox/core/DbxException.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,6 @@ public NetworkIO(IOException underlying)
143143
* Gets thrown when the access token you're using to make API calls is invalid.
144144
*
145145
* <p>
146-
* One potential cause of the error is a programming error on your end. Make sure
147-
* the access token you are passing in to {@link DbxClient} is valid.
148-
* </p>
149-
*
150-
* <p>
151146
* A more typical situation is that your access token <em>was</em> valid, but the
152147
* user has since "unlinked" your application via the Dropbox website
153148
* (<a href="http://www.dropbox.com/account#applications">http://www.dropbox.com/account#applications</a>).

0 commit comments

Comments
 (0)