Box
The box module lets editors search and import files from a linked Box account through Brightspot's federated search.
Dependencies
Depends on db-http and the Box Java SDK (com.box.sdk), which wraps the Box Content API and its OAuth2 authorization flow.
Installation
- Maven
- Gradle
- Gradle (Kotlin DSL)
<!-- Requires Brightspot 5.0 or later. -->
<dependency>
<groupId>com.brightspot.dbhttp</groupId>
<artifactId>box</artifactId>
<version>1.0.0</version>
</dependency>
// Requires Brightspot 5.0 or later.
implementation 'com.brightspot.dbhttp:box:1.0.0'
// Requires Brightspot 5.0 or later.
implementation("com.brightspot.dbhttp:box:1.0.0")
API reference
com.psddev.box.BoxDatabase
Extends HttpDatabase. Searches files (type=file) in the editor's linked Box account and passes offset/limit straight through to Box's native pagination.
com.psddev.box.FederatedBoxFile
Extends ExternalItem, displayed as Box File.
| Field | Type | Description |
|---|---|---|
boxId | String | The Box file Id. |
name | String | The file name. |
createdAt | Date | When the file was created in Box. |
modifiedAt | Date | When the file was last modified in Box. |
description | String | The Box file description. |
size | String | The file size, formatted as a human-readable string. |
createdBy | String | Who created the file in Box. |
modifiedBy | String | Who last modified the file in Box. |
trashedAt | Date | When the file was trashed in Box, if applicable. |
ownedBy | String | The Box account that owns the file. |
sharedLink | String | The file's Box shared link, if one exists. |
tags | List<String> | Tags applied to the file in Box. |
parentFolder | String | The name of the file's parent folder in Box. |
createdBy, modifiedBy, sharedLink, tags, and parentFolder are only populated when an editor opens a file's detail view — search results include only the fields Box returns from its search endpoint.
Configuration
The OAuth2 application key and secret are stored on BoxSettings, a Modification<CmsTool> shown under Site Settings > Integrations > Box. BoxDatabaseProvider throws an exception if these aren't set. Each editor additionally links their own Box account (BoxAccountAccess), surfaced under the editor's user settings, before they can search Box.
Extending the plugin
The module doesn't ship a content type for imported files. To let editors create one from search results, define a content type and extend ExternalItemConverter<FederatedBoxFile, T> to convert the external item into it on import, downloading the file's content through the Box API.