Skip to content

Latest commit

 

History

History
202 lines (162 loc) · 8.28 KB

3.x.x to 4.x.x.md

File metadata and controls

202 lines (162 loc) · 8.28 KB

Migration guide for versions 3.x.x -> 4.x.x

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.

Configuration changes

BoxDeveloperEditionAPIConnection

Replaced com.box.sdk.BoxDeveloperEditionAPIConnection#getAppUserConnectionwith com.box.sdk.BoxDeveloperEditionAPIConnection#getUserConnection.

Example

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);

Documentation

You can read more on BoxDeveloperEditionAPIConnection here.

MaxRequestAttempts

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.

Removed deprecated methods and classes

  1. com.box.sdk.BoxAPIRequest.BoxAPIRequest(java.net.URL, java.lang.String) - use constuctor that accepts com.box.sdk.BoxAPIConnection.
  2. 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 using com.box.sdk.BoxUser.transferContent.

Replaced methods and classes

Getting thumbnail

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).

Example

To read the PDF representation of file with id 12345:

ByteArrayOutputStream output = new ByteArrayOutputStream();

BoxFile file = new BoxFile(api, "12345");
file.getRepresentationContent("[pdf]", output);

Documentation

For more details on getting representation content go here.

Shared links

Removed variant of methods that do not use com.box.sdk.sharedlink.BoxSharedLinkRequest:

  1. com.box.sdk.BoxItem.createSharedLink
  2. com.box.sdk.BoxFile.createSharedLink
  3. com.box.sdk.BoxFolder.createSharedLink
  4. com.box.sdk.BoxWebLink.createSharedLink

Example

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);

Documentation

For details on shared links, see:

  1. Create shared link for file
  2. Create shared link for folder
  3. Create shared link for web link

Retention Policies

Removed variant of methods that were not using com.box.sdk.BoxRetentionPolicy.BoxRetentionPolicyAction:

  1. com.box.sdk.BoxRetentionPolicy.createFinitePolicy

Example

If you want to create a finite retention policy:

BoxRetentionPolicy.createFinitePolicy(api, "My 30 days retention policy", 30, BoxRetentionPolicyAction.PermanentlyDelete);

Documentation

You can read more on creating retention policies here.

Enterprise Events

Removed variant of methods that were not using com.box.sdk.EnterpriseEventsRequest:

  1. com.box.sdk.EventLog.getEnterpriseEvents

Example

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

Documentation

You can read more on getting enterprise events here.

Search

Method com.box.sdk.BoxFolder.search is replaced with class com.box.sdk.BoxSearch.

Example

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);

Documentation

You can read more on search here.

BoxGroup

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.

Example

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);

Documentation

You can read more on groups here.

MetadataTemplate

In com.box.sdk.MetadataTemplate methods that do not use com.box.sdk.MetadataQuery were removed.

Example

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);

Documentation

You can read more on how to execute metadata query here.

Others

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