Microsoft Drives
The microsoft-drives module lets editors search and import files from OneDrive or SharePoint through Brightspot's federated search, and can convert imported documents and spreadsheets into other Brightspot content.
Dependencies
Depends on db-http, the Microsoft Graph Java SDK, and the platform's shared com.psddev:microsoft-core module for Microsoft app registration and per-user sign-in (MSAL4J-based OAuth2).
Installation
- Maven
- Gradle
- Gradle (Kotlin DSL)
<!-- Requires Brightspot 5.0 or later. -->
<dependency>
<groupId>com.brightspot.dbhttp</groupId>
<artifactId>microsoft-drives</artifactId>
<version>1.0.0</version>
</dependency>
// Requires Brightspot 5.0 or later.
implementation 'com.brightspot.dbhttp:microsoft-drives:1.0.0'
// Requires Brightspot 5.0 or later.
implementation("com.brightspot.dbhttp:microsoft-drives:1.0.0")
API reference
brightspot.microsoft.drives.MicrosoftDrivesDatabase
Extends HttpDatabase. Searches Microsoft Graph's /search/query endpoint, filterable by file type and creator, and fetches file details in batched Graph API requests. Search and detail results are cached for five minutes.
brightspot.microsoft.drives.MicrosoftDrivesFile
Extends ExternalItem.
| Field | Type | Description |
|---|---|---|
fileId | String | The Microsoft Graph item Id. |
name | String | The file name. |
cdnUrl | String | A CDN-served URL for the file. |
webUrl | String | A link to view the file in OneDrive or SharePoint. |
createdAtDate | Date | When the file was created. |
lastUpdateDate | Date | When the file was last modified. Filterable in search. |
mimeType | String | The file's MIME type. |
contentSize | Long | The file size in bytes. |
Configuration
Microsoft Drives has no service-specific settings of its own — authentication is handled entirely through the shared Microsoft app registration (MicrosoftApp, configured on the CMS Tool) and each editor's personal Microsoft sign-in. The module requests the User.Read, Files.Read.All, and Sites.Read.All scopes during sign-in.
Extending the plugin
To let editors create a local content record from search results, define a content type and extend UpdatableExternalItemConverter<MicrosoftDrivesFile, T>, implementing both convert (initial import) and update (re-import). Have the content type implement MicrosoftDrivesImport so it can report the file extension it accepts and populate its file and title fields from the imported MicrosoftDrivesFile.
Implementing update also enables sync: MicrosoftDrivesSyncable compares the source file's modified time against the time it was last imported, and an editor can re-import a synced record—producing a draft with the differences if it's published, or updating it directly otherwise.
For Word documents specifically, extend DocumentConverter<T> instead of implementing the interfaces directly—it's an @Embedded converter, configured inline in the CMS, with createType, convert, and update methods that parallel the pattern above. A similar MicrosoftDrivesSpreadsheetConverter base exists for spreadsheets.