Central manager for content assets - images, videos, binary files, text snippets, content items and saved queries. Handles upload, search, field access, translation, relations, CDN publishing and deletion. Registered as the "assetManager" service, so it is reachable from GraalJS controllers and templates under that name, and most of its methods are also exported directly to GraalJS. Delegates persistence and low level storage to AssetService, and rendering of typed field values to a set of FieldRenderer implementations chosen per field definition.
Group: Managers
Properties
| Property | Returns | Description |
|---|---|---|
| assetsAppIndexer | AssetsAppIndexer | The Elasticsearch indexer used for asset and content search. |
| assetService | AssetService | The underlying service used to persist and load assets. |
| assetTypeManager | AssetTypeManager | The asset type manager that resolves and manages asset type definitions. |
| assetTypes | List<AssetType> | All asset types currently registered. |
Methods
newManageAssetResource(Asset item, String childName, CommonCollectionResource parent) · newAssetDeliveryResource(Asset asset) · getAssetUrl(Asset asset) · getAssetUrl(Asset asset, String altFormat) · newAssetDeliveryResource(String path, String type, AssetView assetView) · newAssetDeliveryResource(Asset asset, String childName, AssetsFolder parent) · uploadBinaryAsset(InputStream data, String name, String contentType, String notes) · uploadBinaryAsset(InputStream data, String name, String contentType, String notes, Set<String> tags) · uploadBinaryAsset(InputStream data, String name, String contentType, String notes, Set<String> tags, Long relatedEntityId) · uploadImage(InputStream data, String name, String format, String notes) · uploadImage(InputStream data, String name, String format, String notes, Set<String> assetTypes) · uploadVideo(InputStream data, String name, String format, String notes) · uploadVideo(InputStream data, String name, String format, String notes, Set<String> assetTypes) · uploadBinaryFile(InputStream data, String name, String format, String notes) · uploadBinaryFile(InputStream data, String name, String format, String notes, Set<String> assetTypes) · uploadBinaryFile(InputStream data, String name, String format, String notes, Set<String> assetTypes, Long relatedEntityId) · search(String query, String format) · search(String query, List<String> includedTypeNames, List<String> excludedTypeNames) · search(String query, List<String> includedTypeNames, List<String> excludedTypeNames, SearchProperties props) · search(Set<String> query, List<String> includedTypeNames, List<String> excludedTypeNames, SearchProperties props) · search(Set<String> query, List<String> includedTypeNames, List<String> excludedTypeNames, long tenantId, SearchProperties props) · contentSearch(String query, List<String> includedTypeNames, List<String> excludedTypeNames, int startPosition, int pageSize, String orderBy, String orderDirection) · contentSearch(String query, List<String> includedTypeNames, List<String> excludedTypeNames, SearchProperties props) · createContentItem(ContentType ct) · createContentItem(String name, ContentType ct) · createContentItem(ContentType ct, FormContext rc, long currentUserId) · createContentItem(ContentType ct, String name, FormContext rc, long currentUserId) · createContentItem(ContentType ct, String name, Map<String,String> parameters, long currentUserId) · createAssetQuery(FormContext rc) · createTextAsset(FormContext rc) · rename(Asset newItem, String newName) · update(ContentItemAsset newItem, Map<String,String> params) · update(ContentItemAsset newItem, FormContext fc) · update(QueryAsset newItem, FormContext fc) · update(BinaryAsset binaryAsset, InputStream inputStream) · update(TextAsset asset, InputStream inputStream) · update(TextAsset textAsset, FormContext fc) · find(String id) · find(Relation r) · findSingleRelated(Asset from, String relation) · findRelated(Asset from, String relation) · findByName(String name) · findContentType(String type) · createContentType(String name, String type) · fieldValues(ContentItemAsset asset) · fieldValue(ContentItemAsset asset, ContentTypeFieldDef fieldDef) · fieldValue(ContentItemAsset asset, ContentTypeFieldDef fieldDef, String langCode) · render(ContentItemAsset asset, ContentTypeFieldDef fieldDef) · renderInput(ContentItemAsset asset, ContentTypeFieldDef fieldDef) · readAssetData(BinaryAsset asset, Consumer<InputStream> consumer) · writeAssetData(BinaryAsset asset, OutputStream out) · addAssetType(Asset asset, String assetTypeName, long profileId) · removeAssetType(Asset asset, String assetTypeName, long profileId) · getAssetTypes(Asset asset) · canCreate(Profile currentUser, List<String> types, BaseEntity relatedEntity, Website currentWebsite) · findTagsWhichAllowCreate() · canAccessType(Profile user, AssetType type) · findAction(Asset asset) · findAction(AssetType at, Asset asset) · findView(Asset asset) · findView(AssetType at) · delete(List<String> assetIds) · delete(Asset asset) · evaluateSingleAssetQuery(QueryAsset query, Map<String,Object> context) · evaluateAssetQuery(QueryAsset query) · evaluateAssetQuery(QueryAsset query, String orderField, Boolean orderAscending) · evaluateAssetQuery(QueryAsset query, Map<String,Object> context, String orderField, Boolean orderAscending) · setQueryTargets(QueryAsset asset, List<RuleAndTarget> ruleAndTargets) · getAssetTypeManager() · getFields(ContentItemAsset asset) · getAssetService() · relationsToAssets(boolean isFrom, List<AssetRelation> relations) · isNew(Asset asset) · onCreated(Asset newItem) · onUpdated(Asset updatedItem) · getAssetsAppIndexer() · getText(TextAsset asset) · getText(TextAsset asset, String langCode) · setTranslatedText(TextAsset asset, String langCode, String text) · createTranslation(Asset asset, String createLangCode) · getTranslations(Asset asset) · getCurrentTranslation(Asset asset) · listAvailableAssets(RelationFieldDef def, Asset asset) · findFieldDef(ContentItemAsset asset, String fieldName) · findApplicableAssetTypes(String baseType) · walkAllAssets(Consumer<Asset> c) · importZip(InputStream in) · findAltFormats(BinaryAsset asset) · findHlsPrimaries(VideoAsset asset) · findHlsPrimaries(String sourceVideoHash) · exportAll(OutputStream out) · generateStreamingVideo(VideoAsset videoAsset) · generateStreamingVideo(VideoAsset videoAsset, boolean doAsync) · isPublic(Asset a) · unDeployAssetToCdn(BinaryAsset asset) · deployAssetToCdn(BinaryAsset asset, boolean mustPublish) · deployAssetsToCdn(List<BinaryAsset> assets) · deployAssetToCdn(BinaryAsset asset, ContentDeliveryService foundCdn, Website cdnWebsite) · deployAssetToCdn(BinaryAsset asset, ContentDeliveryService foundCdn, Website cdnWebsite, List<String> cdnPathsToInvalidate) · copy(Asset asset) · getAssetTypes() · findAssetType(String typeName) · setRelatedEntityId(Asset asset, Long relatedEntityId)
newManageAssetResource(Asset item, String childName, CommonCollectionResource parent)
Returns: AbstractManageAssetResource
Creates the editing resource for an existing asset, chosen by the asset's concrete type (content item, image, video, text, binary or query). Used to open the correct "manage" folder for an asset in the asset manager UI.
| Parameter | Description |
|---|---|
item | the asset to create an editing resource for |
childName | the name the resource will be addressed by in its parent collection |
parent | the parent collection resource the new resource will be attached to |
newAssetDeliveryResource(Asset asset)
Returns: AbstractAssetResource
Creates the read/delivery resource for an asset at its default location in the assets folder, using the asset's unique id as the resource name.
| Parameter | Description |
|---|---|
asset | the asset to create a delivery resource for |
getAssetUrl(Asset asset)
Returns: String
Returns the URL to use when linking to an asset. If the asset has previously been redirected to a CDN URL and that URL is cached in KademiWebCacheFilter, the CDN URL is returned directly, avoiding the redirect round-trip. Otherwise the internal asset URL is returned.
| Parameter | Description |
|---|---|
asset | the asset to get the URL for |
getAssetUrl(Asset asset, String altFormat)
Returns: String
Returns the URL to use when linking to an asset in a specific alternate format, e.g. a resized image or transcoded video rendition. Uses the same CDN cache lookup as getAssetUrl(Asset).
| Parameter | Description |
|---|---|
asset | the asset to get the URL for |
altFormat | the alternate format name to append to the path, e.g. "640-480.png", or null for the primary format |
newAssetDeliveryResource(String path, String type, AssetView assetView)
Returns: AbstractAssetResource
Creates the read/delivery resource for the asset at the given path within the assets folder, resolving it to a specific resource type. Used when the concrete asset is not already loaded and only its path and declared type are known.
| Parameter | Description |
|---|---|
path | the path of the asset resource, relative to the assets folder |
type | the resource type to create, e.g. "image", "video", "binary", "text", or an asset type name |
assetView | the view configuration to apply when rendering the resource, or null |
newAssetDeliveryResource(Asset asset, String childName, AssetsFolder parent)
Returns: AbstractAssetResource
Creates the read/delivery resource for an asset, dispatching to the resource type that matches the asset's concrete class (image, video, binary, text, content item or query).
| Parameter | Description |
|---|---|
asset | the asset to create a delivery resource for |
childName | the name the resource will be addressed by in its parent collection |
parent | the parent collection resource the new resource will be attached to |
uploadBinaryAsset(InputStream data, String name, String contentType, String notes)
Returns: Asset
Uploads a new binary asset, inferring its content type from the file name if not supplied and routing it to the video, image or generic binary upload path accordingly.
| Parameter | Description |
|---|---|
data | the file content to upload |
name | the file name, used to infer the content type when contentType is null |
contentType | the MIME type of the file, or null to infer it from the name |
notes | free text notes to store against the asset |
uploadBinaryAsset(InputStream data, String name, String contentType, String notes, Set<String> tags)
Returns: Asset
Uploads a new binary asset with a set of asset type tags applied after creation.
| Parameter | Description |
|---|---|
data | the file content to upload |
name | the file name, used to infer the content type when contentType is null |
contentType | the MIME type of the file, or null to infer it from the name |
notes | free text notes to store against the asset |
tags | the asset type names to apply to the new asset, or null for none |
uploadBinaryAsset(InputStream data, String name, String contentType, String notes, Set<String> tags, Long relatedEntityId)
Returns: Asset
Uploads a new binary asset, inferring its content type when not supplied, routing it to the video, image or generic binary upload path, applying the given asset type tags, linking it to a related entity if one is given, and either publishing it to the CDN (when public) or enqueuing background generation of alternate image formats.
| Parameter | Description |
|---|---|
data | the file content to upload |
name | the file name, used to infer the content type when contentType is null |
contentType | the MIME type of the file, or null to infer it from the name |
notes | free text notes to store against the asset |
tags | the asset type names to apply to the new asset, or null for none |
relatedEntityId | the id of the entity this asset relates to, or null for none |
uploadImage(InputStream data, String name, String format, String notes)
Returns: ImageAsset
Uploads a new image asset.
| Parameter | Description |
|---|---|
data | the image content to upload |
name | the file name |
format | the MIME type of the image |
notes | free text notes to store against the asset |
uploadImage(InputStream data, String name, String format, String notes, Set<String> assetTypes)
Returns: ImageAsset
Uploads a new image asset, extracting media metadata from the file, applying the "public" asset type plus any given asset type tags, and firing the asset created event.
| Parameter | Description |
|---|---|
data | the image content to upload |
name | the file name |
format | the MIME type of the image |
notes | free text notes to store against the asset |
assetTypes | additional asset type names to apply to the new asset, or null for none |
uploadVideo(InputStream data, String name, String format, String notes)
Returns: VideoAsset
Uploads a new video asset.
| Parameter | Description |
|---|---|
data | the video content to upload |
name | the file name |
format | the MIME type of the video |
notes | free text notes to store against the asset |
uploadVideo(InputStream data, String name, String format, String notes, Set<String> assetTypes)
Returns: VideoAsset
Uploads a new video asset, extracting media metadata from the file, applying any given asset type tags, and firing the asset created event.
| Parameter | Description |
|---|---|
data | the video content to upload |
name | the file name |
format | the MIME type of the video |
notes | free text notes to store against the asset |
assetTypes | asset type names to apply to the new asset, or null for none |
uploadBinaryFile(InputStream data, String name, String format, String notes)
Returns: BinaryAsset
Uploads a new generic binary file asset.
| Parameter | Description |
|---|---|
data | the file content to upload |
name | the file name |
format | the MIME type of the file |
notes | free text notes to store against the asset |
uploadBinaryFile(InputStream data, String name, String format, String notes, Set<String> assetTypes)
Returns: BinaryAsset
Uploads a new generic binary file asset with a set of asset type tags applied after creation.
| Parameter | Description |
|---|---|
data | the file content to upload |
name | the file name |
format | the MIME type of the file |
notes | free text notes to store against the asset |
assetTypes | asset type names to apply to the new asset, or null for none |
uploadBinaryFile(InputStream data, String name, String format, String notes, Set<String> assetTypes, Long relatedEntityId)
Returns: BinaryAsset
Uploads a new generic binary file asset, applies the given asset type tags, links it to a related entity if one is given, and fires the asset created event.
| Parameter | Description |
|---|---|
data | the file content to upload |
name | the file name |
format | the MIME type of the file |
notes | free text notes to store against the asset |
assetTypes | asset type names to apply to the new asset, or null for none |
relatedEntityId | the id of the entity this asset relates to, or null for none |
search(String query, String format)
Returns: List<Asset>
Searches for assets matching the given free text query, optionally restricted to a single asset type. Returns at most the first 100 matching assets.
| Parameter | Description |
|---|---|
query | the free text search query, split into terms |
format | the asset type name to restrict results to, or null for all types |
search(String query, List<String> includedTypeNames, List<String> excludedTypeNames)
Returns: List<Asset>
Searches for assets matching the given free text query, restricted to included and excluded asset type names. Returns at most the first 100 matching assets.
| Parameter | Description |
|---|---|
query | the free text search query, split into terms, or null/empty to match all assets |
includedTypeNames | asset type names results must have, or null/empty for no restriction |
excludedTypeNames | asset type names results must not have, or null/empty for no restriction |
search(String query, List<String> includedTypeNames, List<String> excludedTypeNames, SearchProperties props)
Returns: List<Asset>
Searches for assets matching the given free text query, restricted to included and excluded asset type names, with paging controlled by the given search properties.
| Parameter | Description |
|---|---|
query | the free text search query, split into terms, or null/empty to match all assets |
includedTypeNames | asset type names results must have, or null/empty for no restriction |
excludedTypeNames | asset type names results must not have, or null/empty for no restriction |
props | the paging and ordering properties to apply |
search(Set<String> query, List<String> includedTypeNames, List<String> excludedTypeNames, SearchProperties props)
Returns: Pair<List<Asset>,Integer>
Searches for assets matching the given set of query terms, restricted to included and excluded asset type names, with paging controlled by the given search properties, within the current tenant.
| Parameter | Description |
|---|---|
query | the search terms to match, or null/empty to match all assets |
includedTypeNames | asset type names results must have, or null/empty for no restriction |
excludedTypeNames | asset type names results must not have, or null/empty for no restriction |
props | the paging and ordering properties to apply |
search(Set<String> query, List<String> includedTypeNames, List<String> excludedTypeNames, long tenantId, SearchProperties props)
Returns: Pair<List<Asset>,Integer>
Searches for assets matching the given set of query terms within a specific tenant, restricted to included and excluded asset type names, with paging controlled by the given search properties.
| Parameter | Description |
|---|---|
query | the search terms to match, or null/empty to match all assets |
includedTypeNames | asset type names results must have, or null/empty for no restriction |
excludedTypeNames | asset type names results must not have, or null/empty for no restriction |
tenantId | the id of the tenant organisation to search within |
props | the paging and ordering properties to apply |
contentSearch(String query, List<String> includedTypeNames, List<String> excludedTypeNames, int startPosition, int pageSize, String orderBy, String orderDirection)
Returns: List<ContentItemAsset>
Runs a full text search over indexed content items via Elasticsearch and returns matching content items, paged and ordered using the given parameters.
| Parameter | Description |
|---|---|
query | the free text search query, or blank to match all content |
includedTypeNames | content type names results must have, or empty for no restriction |
excludedTypeNames | content type names results must not have, or empty for no restriction |
startPosition | the zero based index of the first result to return |
pageSize | the maximum number of results to return |
orderBy | the field name to order results by |
orderDirection | the sort direction, e.g. "asc" or "desc" |
contentSearch(String query, List<String> includedTypeNames, List<String> excludedTypeNames, SearchProperties props)
Returns: List<ContentItemAsset>
Runs a full text search over indexed content items via Elasticsearch and returns matching content items, paged and ordered using the given search properties.
| Parameter | Description |
|---|---|
query | the free text search query, or blank to match all content |
includedTypeNames | content type names results must have, or empty for no restriction |
excludedTypeNames | content type names results must not have, or empty for no restriction |
props | the paging and ordering properties to apply |
createContentItem(ContentType ct)
Returns: ContentItemAsset
Creates a new content item of the given type, using a randomly generated name and the current user as owner.
| Parameter | Description |
|---|---|
ct | the content type to create an item of |
createContentItem(String name, ContentType ct)
Returns: ContentItemAsset
Creates a new content item of the given type with the given name, owned by the current user.
| Parameter | Description |
|---|---|
name | the name to give the new content item |
ct | the content type to create an item of |
createContentItem(ContentType ct, FormContext rc, long currentUserId)
Returns: ContentItemAsset
Creates a new content item of the given type, taking its name and field values from the given form submission. Generates a random name if none was submitted.
| Parameter | Description |
|---|---|
ct | the content type to create an item of |
rc | the form submission to read the name and field values from |
currentUserId | the id of the profile creating the item |
createContentItem(ContentType ct, String name, FormContext rc, long currentUserId)
Returns: ContentItemAsset
Creates a new content item of the given type and name, taking its field values from the given form submission.
| Parameter | Description |
|---|---|
ct | the content type to create an item of |
name | the name to give the new content item |
rc | the form submission to read field values from |
currentUserId | the id of the profile creating the item |
createContentItem(ContentType ct, String name, Map<String,String> parameters, long currentUserId)
Returns: ContentItemAsset
Creates a new content item of the given type and name, parsing and setting field values from the given raw parameter map, then fires the asset created event.
| Parameter | Description |
|---|---|
ct | the content type to create an item of |
name | the name to give the new content item |
parameters | raw field values keyed by field name, as submitted from a form |
currentUserId | the id of the profile creating the item |
createAssetQuery(FormContext rc)
Returns: QueryAsset
Creates a new saved asset query, named from the given form submission and owned by the current user.
| Parameter | Description |
|---|---|
rc | the form submission to read the name from |
createTextAsset(FormContext rc)
Returns: TextAsset
Creates a new text asset, reading its name, format, text content and notes from the given form submission, owned by the current user.
| Parameter | Description |
|---|---|
rc | the form submission to read the name, format, text and notes from |
rename(Asset newItem, String newName)
Returns: void
Renames an asset, as the current user. The rename is only applied when the given name matches the asset's existing name.
| Parameter | Description |
|---|---|
newItem | the asset to rename |
newName | the name to set |
update(ContentItemAsset newItem, Map<String,String> params)
Returns: void
Updates a content item's name and field values from a raw parameter map, as the current user, renaming it first if the name has changed, then firing the asset updated event.
| Parameter | Description |
|---|---|
newItem | the content item to update |
params | raw field values keyed by field name, as submitted from a form |
update(ContentItemAsset newItem, FormContext fc)
Returns: void
Updates a content item's name and field values from a form submission, as the current user, renaming it first if the name has changed, then firing the asset updated event.
| Parameter | Description |
|---|---|
newItem | the content item to update |
fc | the form submission to read the name and field values from |
update(QueryAsset newItem, FormContext fc)
Returns: void
Updates a saved query asset's name, target asset type and notes from a form submission, as the current user, then fires the asset updated event.
| Parameter | Description |
|---|---|
newItem | the query asset to update |
fc | the form submission to read the name, target asset type and notes from |
update(BinaryAsset binaryAsset, InputStream inputStream)
Returns: void
Replaces a binary asset's stored file content, as the current user, fires the asset updated event, then republishes it to the CDN if it is public.
| Parameter | Description |
|---|---|
binaryAsset | the binary asset to update |
inputStream | the new file content |
update(TextAsset asset, InputStream inputStream)
Returns: void
Replaces a text asset's stored content from a raw input stream, as the current user, then fires the asset updated event.
| Parameter | Description |
|---|---|
asset | the text asset to update |
inputStream | the new content |
update(TextAsset textAsset, FormContext fc)
Returns: void
Updates a text asset's name, format, text and notes from a form submission, as the current user, then fires the asset updated event.
| Parameter | Description |
|---|---|
textAsset | the text asset to update |
fc | the form submission to read the name, format, text and notes from |
find(String id)
Returns: Asset
Finds an asset by its unique id.
| Parameter | Description |
|---|---|
id | the asset's unique id |
find(Relation r)
Returns: Asset
Finds the asset that a relation points to.
| Parameter | Description |
|---|---|
r | the relation whose target asset is looked up, or null |
findSingleRelated(Asset from, String relation)
Returns: Asset
Finds the first asset related to the given asset by the named relation.
| Parameter | Description |
|---|---|
from | the asset whose relations are searched, or null |
relation | the relation name to look for |
findRelated(Asset from, String relation)
Returns: List<Asset>
Finds all assets related to the given asset by the named relation.
| Parameter | Description |
|---|---|
from | the asset whose relations are searched |
relation | the relation name to look for |
findByName(String name)
Returns: Asset
Finds an asset by its name.
| Parameter | Description |
|---|---|
name | the asset name to look up |
findContentType(String type)
Returns: ContentType
Finds a registered content type by name.
| Parameter | Description |
|---|---|
type | the content type name to look up |
createContentType(String name, String type)
Returns: AssetType
Creates a new asset type definition with the given name and base type.
| Parameter | Description |
|---|---|
name | the name of the new asset type |
type | the base type to create the new asset type as |
fieldValues(ContentItemAsset asset)
Returns: Map<String,Object>
Returns the raw field values stored against a content item, keyed by field name.
| Parameter | Description |
|---|---|
asset | the content item to read field values from |
fieldValue(ContentItemAsset asset, ContentTypeFieldDef fieldDef)
Returns: Object
Returns the typed value of a single field on a content item, in the currently selected translation language.
| Parameter | Description |
|---|---|
asset | the content item to read the field value from |
fieldDef | the field definition to read |
fieldValue(ContentItemAsset asset, ContentTypeFieldDef fieldDef, String langCode)
Returns: Object
Returns the typed value of a single field on a content item, using the given language's translation of the asset if one exists and a language code is supplied.
| Parameter | Description |
|---|---|
asset | the content item to read the field value from, or null |
fieldDef | the field definition to read, or null |
langCode | the language code to look up a translation for, or blank to use the asset as given |
render(ContentItemAsset asset, ContentTypeFieldDef fieldDef)
Returns: String
Renders a content item field to its display representation using the field's renderer.
| Parameter | Description |
|---|---|
asset | the content item to render the field from |
fieldDef | the field definition to render |
renderInput(ContentItemAsset asset, ContentTypeFieldDef fieldDef)
Returns: String
Renders the editable input control for a content item field using the field's renderer.
| Parameter | Description |
|---|---|
asset | the content item the input is for |
fieldDef | the field definition to render an input for |
readAssetData(BinaryAsset asset, Consumer<InputStream> consumer)
Returns: void
Reads a binary asset's stored content, passing an input stream to the given consumer.
| Parameter | Description |
|---|---|
asset | the binary asset to read |
consumer | the callback invoked with the asset's content stream |
writeAssetData(BinaryAsset asset, OutputStream out)
Returns: void
Writes a binary asset's stored content to the given output stream.
| Parameter | Description |
|---|---|
asset | the binary asset to read |
out | the stream to write the asset's content to |
addAssetType(Asset asset, String assetTypeName, long profileId)
Returns: void
Applies an asset type tag to an asset and fires the asset updated event.
| Parameter | Description |
|---|---|
asset | the asset to tag |
assetTypeName | the asset type name to apply |
profileId | the id of the profile performing the change |
removeAssetType(Asset asset, String assetTypeName, long profileId)
Returns: void
Removes an asset type tag from an asset and fires the asset updated event.
| Parameter | Description |
|---|---|
asset | the asset to untag |
assetTypeName | the asset type name to remove |
profileId | the id of the profile performing the change |
getAssetTypes(Asset asset)
Returns: List<AssetType>
Resolves an asset's asset type tags to their registered asset type definitions, skipping any tag names that are not currently registered.
| Parameter | Description |
|---|---|
asset | the asset to resolve asset types for |
canCreate(Profile currentUser, List<String> types, BaseEntity relatedEntity, Website currentWebsite)
Returns: boolean
Checks whether a user is allowed to create assets of any of the given types. Admins are always allowed. Otherwise checks whether the user has the content author role over the related entity's organisation, the account organisation, or the given website, then falls back to checking each asset type's own creation permissions (by group, by organisation, or by relation to the related entity).
| Parameter | Description |
|---|---|
currentUser | the user to check, or null |
types | the asset type names creation is being requested for, or null |
relatedEntity | the entity the new asset would relate to, or null |
currentWebsite | the website the creation is happening in the context of, or null |
findTagsWhichAllowCreate()
Returns: List<String>
Finds the asset type names that have at least one permission allowing creation.
canAccessType(Profile user, AssetType type)
Returns: boolean
Checks whether a user can access an asset type, based on the type's configured permissions (by group and/or organisation, or the public group).
| Parameter | Description |
|---|---|
user | the user to check |
type | the asset type to check access to |
findAction(Asset asset)
Returns: AssetAction
Finds the first matching controller action for an asset, checked across each of the asset's resolved asset types.
| Parameter | Description |
|---|---|
asset | the asset to find an action for |
findAction(AssetType at, Asset asset)
Returns: AssetAction
Finds the first controller method on the given asset type whose matcher matches the asset, and returns its action.
| Parameter | Description |
|---|---|
at | the asset type to search for a matching controller method, or null |
asset | the asset to test each controller method's matcher against |
findView(Asset asset)
Returns: AssetView
Finds the view to use for rendering an asset, checked across each of the asset's resolved asset types, falling back to the first configured default view.
| Parameter | Description |
|---|---|
asset | the asset to find a view for |
findView(AssetType at)
Returns: AssetView
Finds the first view on the given asset type whose matcher matches with no asset, i.e. an unconditional or asset-independent matcher.
| Parameter | Description |
|---|---|
at | the asset type to search for a matching view |
delete(List<String> assetIds)
Returns: void
Deletes the assets with the given unique ids, firing the asset deleted event for each one found before it is removed.
| Parameter | Description |
|---|---|
assetIds | the unique ids of the assets to delete |
delete(Asset asset)
Returns: void
Deletes a single asset, firing the asset deleted event first.
| Parameter | Description |
|---|---|
asset | the asset to delete |
evaluateSingleAssetQuery(QueryAsset query, Map<String,Object> context)
Returns: Asset
Evaluates a saved query's rules against the given context and returns the first matching asset for the first rule whose conditions match the current user.
| Parameter | Description |
|---|---|
query | the saved query to evaluate |
context | contextual data available to the query rules |
evaluateAssetQuery(QueryAsset query)
Returns: List<Asset>
Evaluates a saved query with an empty context and no explicit ordering.
| Parameter | Description |
|---|---|
query | the saved query to evaluate |
evaluateAssetQuery(QueryAsset query, String orderField, Boolean orderAscending)
Returns: List<Asset>
Evaluates a saved query with an empty context, ordering results by the given field.
| Parameter | Description |
|---|---|
query | the saved query to evaluate |
orderField | the field name to order results by, or null for no explicit ordering |
orderAscending | true to sort ascending, false to sort descending, or null for no explicit ordering |
evaluateAssetQuery(QueryAsset query, Map<String,Object> context, String orderField, Boolean orderAscending)
Returns: List<Asset>
Evaluates a saved query's rules against the given context. If the query has no rules, falls back to searching by its target asset type. Otherwise evaluates each rule's conditions against the current user in turn and returns the results of the first one that matches, up to 1000 results.
| Parameter | Description |
|---|---|
query | the saved query to evaluate, or null |
context | contextual data available to the query rules |
orderField | the field name to order results by, or null for no explicit ordering |
orderAscending | true to sort ascending, false to sort descending, or null for no explicit ordering |
setQueryTargets(QueryAsset asset, List<RuleAndTarget> ruleAndTargets)
Returns: void
Sets the target rules for a saved query.
| Parameter | Description |
|---|---|
asset | the saved query to update |
ruleAndTargets | the rule and target pairs to set on the query |
getAssetTypeManager()
Returns: AssetTypeManager
The asset type manager that resolves and manages asset type definitions.
getFields(ContentItemAsset asset)
Returns: List<ContentTypeFieldDef>
Returns all field definitions applicable to a content item, collected across each of its asset types with later types overriding fields of the same name from earlier ones.
| Parameter | Description |
|---|---|
asset | the content item to collect field definitions for |
getAssetService()
Returns: AssetService
The underlying service used to persist and load assets.
relationsToAssets(boolean isFrom, List<AssetRelation> relations)
Returns: List<Asset>
Resolves a list of asset relations to the assets on one side of each relation, removing duplicates.
| Parameter | Description |
|---|---|
isFrom | true to take the "from" asset of each relation, false to take the "to" asset |
relations | the relations to resolve |
isNew(Asset asset)
Returns: boolean
Checks whether an asset has not yet been persisted.
| Parameter | Description |
|---|---|
asset | the asset to check |
onCreated(Asset newItem)
Returns: void
Runs any asset type "on created" event handlers configured for the asset's types, updates the search index, and fires the asset created event. Called after a new asset has been persisted.
| Parameter | Description |
|---|---|
newItem | the newly created asset |
onUpdated(Asset updatedItem)
Returns: void
Saves and flushes the asset, runs any asset type "on updated" event handlers configured for the asset's types, updates the search index, and fires the asset updated event. Called after an asset's fields or content have changed.
| Parameter | Description |
|---|---|
updatedItem | the updated asset |
getAssetsAppIndexer()
Returns: AssetsAppIndexer
The Elasticsearch indexer used for asset and content search.
getText(TextAsset asset)
Returns: String
Returns a text asset's content in the currently selected translation language.
| Parameter | Description |
|---|---|
asset | the text asset to read |
getText(TextAsset asset, String langCode)
Returns: String
Returns a text asset's content, using the given language's translation if one exists and a language code is supplied.
| Parameter | Description |
|---|---|
asset | the text asset to read |
langCode | the language code to look up a translation for, or blank to use the asset's own text |
setTranslatedText(TextAsset asset, String langCode, String text)
Returns: void
Stores a translation of a text asset's content for the given language.
| Parameter | Description |
|---|---|
asset | the text asset the translation is for |
langCode | the language code the translation is in |
text | the translated text |
createTranslation(Asset asset, String createLangCode)
Returns: Asset
Creates a copy of an asset in a new language, ready for its content to be translated, and links it back to the original with "translation" and "translation-source" relations.
| Parameter | Description |
|---|---|
asset | the asset to translate |
createLangCode | the language code of the new translation, must differ from the asset's own language |
getTranslations(Asset asset)
Returns: List<Asset>
Finds all existing translations of an asset.
| Parameter | Description |
|---|---|
asset | the asset to find translations of |
getCurrentTranslation(Asset asset)
Returns: Asset
Returns the translation of an asset for the currently selected language, if one exists.
| Parameter | Description |
|---|---|
asset | the asset to find the current-language translation of |
listAvailableAssets(RelationFieldDef def, Asset asset)
Returns: List<Asset>
Lists candidate assets that could be linked via a relation field, restricted to the field's target content type. Returns up to 1000 results.
| Parameter | Description |
|---|---|
def | the relation field definition specifying the target content type |
asset | the asset the relation would be set on, currently unused when building the candidate list |
findFieldDef(ContentItemAsset asset, String fieldName)
Returns: ContentTypeFieldDef
Finds a content item's field definition by name.
| Parameter | Description |
|---|---|
asset | the content item to search field definitions for, or null |
fieldName | the field name to look up, or blank |
findApplicableAssetTypes(String baseType)
Returns: Set<ContentType>
Finds the concrete (non-abstract) content types that apply to a base asset type, including the base type itself and all of its registered subtypes.
| Parameter | Description |
|---|---|
baseType | the base asset type name to find applicable content types for |
walkAllAssets(Consumer<Asset> c)
Returns: void
Iterates over every asset in the tenant, invoking the given consumer for each one and logging progress every 10 assets.
| Parameter | Description |
|---|---|
c | the callback invoked with each asset |
importZip(InputStream in)
Returns: void
Imports assets previously exported with exportAll. Reads a zip stream of paired "-meta" and "-content" entries, restores each asset from its metadata, applies its content, recreates any relations that had to be deferred until all assets existed, and finally republishes restored videos, PDFs and public images to the CDN.
| Parameter | Description |
|---|---|
in | the zip stream to import |
findAltFormats(BinaryAsset asset)
Returns: List<AltFormatBean>
Finds the alternate rendered formats, e.g. resized images, generated from a binary asset's content hash.
| Parameter | Description |
|---|---|
asset | the binary asset to find alternate formats for |
findHlsPrimaries(VideoAsset asset)
Returns: HlsPrimaryBean
Finds the HLS streaming metadata generated for a video asset's content hash.
| Parameter | Description |
|---|---|
asset | the video asset to find HLS streaming metadata for |
findHlsPrimaries(String sourceVideoHash)
Returns: HlsPrimaryBean
Finds the HLS streaming metadata generated for a video content hash.
| Parameter | Description |
|---|---|
sourceVideoHash | the video content hash to find HLS streaming metadata for |
exportAll(OutputStream out)
Returns: void
Exports every asset in the tenant to a zip stream, writing a metadata entry and, where available, a content entry for each one. Produces the format read by importZip.
| Parameter | Description |
|---|---|
out | the stream to write the zip export to |
generateStreamingVideo(VideoAsset videoAsset)
Returns: void
Enqueues a background task to generate a streaming format and thumbnails for the given video asset, publishing to the best available content delivery website.
| Parameter | Description |
|---|---|
videoAsset | the video asset to generate streaming output for |
generateStreamingVideo(VideoAsset videoAsset, boolean doAsync)
Returns: void
Generates a streaming format and thumbnails for the given video asset, publishing to the best available content delivery website.
| Parameter | Description |
|---|---|
videoAsset | the video asset to generate streaming output for |
doAsync | true to run the conversion via the background job manager, false to initiate it synchronously (the underlying provider, e.g. AWS Elastic Transcoder, may still complete it asynchronously) |
isPublic(Asset a)
Returns: boolean
Checks whether an asset is tagged with the "public" asset type.
| Parameter | Description |
|---|---|
a | the asset to check |
unDeployAssetToCdn(BinaryAsset asset)
Returns: boolean
Removes an asset's published CDN URLs, for images including all of its alternate formats. Video assets cannot be undeployed.
| Parameter | Description |
|---|---|
asset | the binary asset to remove from the CDN |
deployAssetToCdn(BinaryAsset asset, boolean mustPublish)
Returns: boolean
Deploys a binary asset to the CDN, using the first non-alias, non-redirect website with a configured content delivery service.
| Parameter | Description |
|---|---|
asset | the binary asset to deploy |
mustPublish | true to throw if no CDN is configured, false to return false in that case |
deployAssetsToCdn(List<BinaryAsset> assets)
Returns: int
Deploys multiple binary assets to the CDN, firing a single batched invalidation covering all of them at the end instead of one per asset.
| Parameter | Description |
|---|---|
assets | the assets to publish |
deployAssetToCdn(BinaryAsset asset, ContentDeliveryService foundCdn, Website cdnWebsite)
Returns: boolean
Deploys a single asset to the CDN, firing an invalidation immediately.
| Parameter | Description |
|---|---|
asset | the asset to publish |
foundCdn | the CDN service to publish to |
cdnWebsite | the website associated with the CDN distribution |
deployAssetToCdn(BinaryAsset asset, ContentDeliveryService foundCdn, Website cdnWebsite, List<String> cdnPathsToInvalidate)
Returns: boolean
Deploys a single asset to the CDN, optionally deferring invalidation so callers can batch it across multiple assets.
| Parameter | Description |
|---|---|
asset | the asset to publish |
foundCdn | the CDN service to publish to |
cdnWebsite | the website associated with the CDN distribution |
cdnPathsToInvalidate | if non-null, CDN paths are collected here instead of invalidating immediately |
copy(Asset asset)
Returns: Asset
Creates a duplicate of an asset.
| Parameter | Description |
|---|---|
asset | the asset to copy |
getAssetTypes()
Returns: List<AssetType>
All asset types currently registered.
findAssetType(String typeName)
Returns: AssetType
Finds a registered asset type by name.
| Parameter | Description |
|---|---|
typeName | the asset type name to look up |
setRelatedEntityId(Asset asset, Long relatedEntityId)
Returns: void
Links an asset to a related entity by id, then fires the asset updated event. Does nothing if either argument is null.
| Parameter | Description |
|---|---|
asset | the asset to update |
relatedEntityId | the id of the entity the asset relates to |