Associated Press
The associated-press module lets editors search and import licensed images from the Associated Press Content API through Brightspot's federated search.
Dependencies
Depends on db-http and the AP Content API (media/v/content/search), authenticated with an x-api-key header.
Installation
- Maven
- Gradle
- Gradle (Kotlin DSL)
<!-- Requires Brightspot 5.0 or later. -->
<dependency>
<groupId>com.brightspot.dbhttp</groupId>
<artifactId>associated-press</artifactId>
<version>1.0.0</version>
</dependency>
// Requires Brightspot 5.0 or later.
implementation 'com.brightspot.dbhttp:associated-press:1.0.0'
// Requires Brightspot 5.0 or later.
implementation("com.brightspot.dbhttp:associated-press:1.0.0")
API reference
com.psddev.ap.AssociatedPressDatabase
Extends HttpDatabase. Every search is restricted to type:(picture), and results are filtered to only images whose AP use code permits licensing under the account's plan. To reduce redundant full-text queries, the database caches AP's continuation token (qt) per editor for two minutes and reuses it when paging through the same search.
com.psddev.ap.AssociatedPressImage
Extends ExternalItem, displayed as AP Image.
| Field | Type | Description |
|---|---|---|
title | String | The image's title. |
apId | String | The AP Id. |
previewUrl | String | A preview image URL. |
creditLine | String | The AP credit line. |
copyrightNotice | String | The AP copyright notice. |
provider | String | The content provider. |
caption | String | The image caption. |
price | String | The AP pricing tier for this image. |
pricingMessage | String | A human-readable pricing message from AP. |
Sort order is set through the AssociatedPressImageSort enum: NEWEST (default), OLDEST, or RELEVANCE.
Configuration
The API key is stored on com.psddev.ap.AssociatedPressApiClient (name, apiKey), referenced from AssociatedPressSettings, a Modification<SiteSettings> shown under Site Settings > Integrations > Associated Press. AssociatedPressDatabaseProvider resolves the per-site client and constructs the database. A custom style sheet is only injected into CMS tool pages when a site has AP enabled.
Extending the plugin
The module doesn't ship a content type for imported images. To let editors create one from search results, define a content type and extend ExternalItemConverter<AssociatedPressImage, T> to convert the external item into it on import, downloading the image with AssociatedPressImage#generateStorageItemFromUrl.