box/box-java-sdk-v2 — pull request #105 by jianbox (2014-03-17 17:07:18+00:00)
Title: V3

Refactored the sdk, main purpose is to make exposed interfaces cleaner and easier to use.

Migration will be needed:
- Resource manager interfaces.
pre-v3, our boxClient.get***Manager() method returns concrete class of resource managers. For the purpose of a cleaner interface, in v3, they return resource manager interfaces.
old code:
BoxFilesManager filesManager = boxClient.getFilesManager();
filesManager.doSomething(...);
new code:
IBoxFilesManager filesManager = boxClient.getFilesManager();
filesManager.doSomething(...);

- Made certain methods more convenient, e.g., OAuth api related methods:
old code:
BoxOAuthRequestObject obj = BoxOAuthRequestObject.crateOAuthRequestObject(code, clientId, clientSecret, redirectUrl);
BoxOAuthData oauth = oauthManager.createOAuth(obj);
new Code:
BoxOAuthData oauth = oauthManager.createOAuth(code, clientId, clientSecret, redirectUrl);

- BoxFilesManager/BoxFoldersManager. Methods acting upon BoxItems are moved to BoxItemsManager to avoid confusion.
Example, get a BoxFile.
Old code:
Two ways to get it:
1. boxClient.getFilesManager.getFile(fileId, null);
2. boxClient.getFilesManager.getItem(fileId, null, BoxResourceType.FILE);
New code:
Two ways to get it:
1. same as old code.
2. boxClient.getBoxItemsManager.getItem(fileId, null, BoxResourceType.FILE);

- Trash Manager: old code has methods for trashed files/folders in FilesManager/FoldersManager, new code moved them into a trash manager.
Example:
old code:
boxClient.getFilesManager.getTrashFile(fileId, null);
new code:
boxClient.getTrashManager.getTrashFile(fileId, null);

- request objects: To avoid confusion, request objects now are more api specific. There are some type changes, however the way you used to write the code remain the same. One example:
Old code of create a shared link.
BoxFileRequestObject obj = BoxFileRequestObject. createSharedLinkRequestObject(......);
filesManager.createSharedLink(fileId, obj);
New code:
BoxSharedLinkRequestObject obj =
BoxSharedLinkRequestObject.
createSharedLinkRequestObject(sharedLinkEntity);
filesManager.createSharedLink(fileId, obj);

Also in order to provide cleaner interface, we moved the setters for basic http requests in the request objects to a "requestExtra".
Old code:
requestObject.addField("some field");
new code:
requestObject.getRequestExtras().addField("some field");

(Optional/Deprecated)
- utils methods in resource managers.
In case you were using the utils methods in resource managers to filter for specific items from collection, they are now deprecated and moved to util methods.
old code:
List filesInCollection = BoxFilesManager.getFiles(collection);
new code:
List filesInCollection = Utils.getTypedObjects(collection, BoxFile.class);

- get thumbnail.
old code:
InputStream is = filesManager.downloadThumbnail(fileId, extension, null);
new code:
BoxThumbnail thumbnail = filesManager.downloadThumbnail(fileId, extension, null);