The most important change this release includes is the replacement of the HTTP library from a native one to OkHttp which allows SDK to:
- Support the HTTP2 version of the HTTP protocol.
- Support proxies that do not use only basic authentication method. For details on creating custom proxy authenticators and an example of NTLM proxy authentication, see here.
Replaced com.box.sdk.BoxDeveloperEditionAPIConnection#getAppUserConnection
with com.box.sdk.BoxDeveloperEditionAPIConnection#getUserConnection
.
To create com.box.sdk.BoxDeveloperEditionAPIConnection
configured for user access:
Reader reader = new FileReader("some-config.json");
BoxConfig boxConfig = BoxConfig.readFrom(reader);
BoxDeveloperEditionAPIConnection api = BoxDeveloperEditionAPIConnection.getUserConnection(boxConfig);
You can read more on BoxDeveloperEditionAPIConnection here.
The MaxRequestAttempts
are removed from com.box.sdk.BoxGlobalSettings
and replaced with MaxRetryAttempts
.
However, if you have API connection stored with the deprecated MaxRequestAttempts
value it will be restored into MaxRetryAttempts
.
com.box.sdk.BoxAPIRequest.BoxAPIRequest(java.net.URL, java.lang.String)
- use constuctor that acceptscom.box.sdk.BoxAPIConnection
.com.box.sdk.BoxUser.moveFolderToUser
- this method is removed as this operation is not allowed by API. You can only transfer root folder to another user usingcom.box.sdk.BoxUser.transferContent
.
Method com.box.sdk.BoxFile.getThumbnail
was removed. To get any file representation use com.box.sdk.BoxFile.getRepresentationContent(java.lang.String, java.io.OutputStream)
or com.box.sdk.BoxFile.getRepresentationContent(java.lang.String, java.lang.String, java.io.OutputStream)
.
To read the PDF representation of file with id 12345
:
ByteArrayOutputStream output = new ByteArrayOutputStream();
BoxFile file = new BoxFile(api, "12345");
file.getRepresentationContent("[pdf]", output);
For more details on getting representation content go here.
Removed variant of methods that do not use com.box.sdk.sharedlink.BoxSharedLinkRequest
:
com.box.sdk.BoxItem.createSharedLink
com.box.sdk.BoxFile.createSharedLink
com.box.sdk.BoxFolder.createSharedLink
com.box.sdk.BoxWebLink.createSharedLink
If you want to create a shared link, first create com.box.sdk.sharedlink.BoxSharedLinkRequest
:
Date unsharedDate = ...
BoxFile file = new BoxFile(api, "id");
BoxSharedLinkRequest sharedLinkRequest = new BoxSharedLinkRequest()
.access(OPEN)
.permissions(true, true)
.unsharedDate(unsharedDate);
BoxSharedLink sharedLink = file.createSharedLink(sharedLinkRequest);
For details on shared links, see:
Removed variant of methods that were not using com.box.sdk.BoxRetentionPolicy.BoxRetentionPolicyAction
:
com.box.sdk.BoxRetentionPolicy.createFinitePolicy
If you want to create a finite retention policy:
BoxRetentionPolicy.createFinitePolicy(api, "My 30 days retention policy", 30, BoxRetentionPolicyAction.PermanentlyDelete);
You can read more on creating retention policies here.
Removed variant of methods that were not using com.box.sdk.EnterpriseEventsRequest
:
com.box.sdk.EventLog.getEnterpriseEvents
If you want to get historical enterprise events, first create com.box.sdk.EnterpriseEventsRequest
:
EnterpriseEventsRequest request = new EnterpriseEventsRequest().limit(20);
EventLog.getEnterpriseEvents(api, request1);
// process recieved events
You can read more on getting enterprise events here.
Method com.box.sdk.BoxFolder.search
is replaced with class com.box.sdk.BoxSearch
.
If you would like to find the first 10 files matching "taxes":
long offsetValue = 0;
long limitValue = 10;
BoxSearchParameters searchParams = new BoxSearchParameters();
searchParams.setQuery("taxes");
searchParams.setType("file");
BoxSearch boxSearch = new BoxSearch(api);
boxSearch.searchRange(offsetValue, limitValue, searchParams);
You can read more on search here.
All methods that use com.box.sdk.BoxGroupMembership.Role
were removed. Use ones that use com.box.sdk.BoxGroupMembership.GroupRole
.
Also com.box.sdk.BoxGroupMembership.Role
was replaced with com.box.sdk.BoxGroupMembership.GroupRole
.
To add a new member to a group with specific role:
BoxUser user = ...
BoxGroup boxGroup = new BoxGroup(api, "group_id");
boxGroup.addMembership(user, BoxGroupMembership.GroupRole.ADMIN);
To get membership role use com.box.sdk.BoxGroupMembership.Info.getGroupRole
:
BoxGroupMembership membership = new BoxGroupMembership(api, "membership_id");
membership.getInfo().getGroupRole();
To change membership role use com.box.sdk.BoxGroupMembership.Info.setGroupRole
:
BoxGroupMembership membership = new BoxGroupMembership(api, "membership_id");
BoxGroupMembership.Info membershipInfo = membership.getInfo();
membershipInfo.setGroupRole(BoxGroupMembership.GroupRole.MEMBER);
membership.updateInfo(membershipInfo);
You can read more on groups here.
In com.box.sdk.MetadataTemplate
methods that do not use com.box.sdk.MetadataQuery
were removed.
To execute a metadata query first create com.box.sdk.MetadataQuery
instance.
MetadataQuery mQuery = new MetadataQuery("enterprise_341532.test");
mQuery.setQuery("testfield = :arg");
mQuery.setAncestorFolderId("0");
mQuery.setOrderBy(
MetadataQuery.OrderBy.ascending("primarySortKey"),
MetadataQuery.OrderBy.ascending("secondarySortKey")
);
mQuery.addParameter("arg", "test");
mQuery.setFields("metadata.enterprise_341532.test.customField");
MetadataTemplate.executeMetadataQuery(api, mQuery);
You can read more on how to execute metadata query here.
Old | New |
---|---|
com.box.sdk.BoxEvent.getType |
com.box.sdk.BoxEvent.getEventType |
com.box.sdk.BoxEvent.Type |
com.box.sdk.BoxEvent.EventType |
com.box.sdk.BoxFile.uploadVersion |
com.box.sdk.BoxFile.uploadNewVersion |
com.box.sdk.BoxGlobalSettings.getMaxRequestAttempts |
com.box.sdk.BoxGlobalSettings.getMaxRetryAttempts |
com.box.sdk.BoxGlobalSettings.setMaxRequestAttempts |
com.box.sdk.BoxGlobalSettings.setMaxRetryAttempts |
com.box.sdk.BoxTask.Info.getAction |
com.box.sdk.BoxTask.Info.getTaskType |