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

PropertyReturnsDescription
assetsAppIndexerAssetsAppIndexerThe Elasticsearch indexer used for asset and content search.
assetServiceAssetServiceThe underlying service used to persist and load assets.
assetTypeManagerAssetTypeManagerThe asset type manager that resolves and manages asset type definitions.
assetTypesList<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.

ParameterDescription
itemthe asset to create an editing resource for
childNamethe name the resource will be addressed by in its parent collection
parentthe 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.

ParameterDescription
assetthe 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.

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

ParameterDescription
assetthe asset to get the URL for
altFormatthe 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.

ParameterDescription
paththe path of the asset resource, relative to the assets folder
typethe resource type to create, e.g. "image", "video", "binary", "text", or an asset type name
assetViewthe 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).

ParameterDescription
assetthe asset to create a delivery resource for
childNamethe name the resource will be addressed by in its parent collection
parentthe 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.

ParameterDescription
datathe file content to upload
namethe file name, used to infer the content type when contentType is null
contentTypethe MIME type of the file, or null to infer it from the name
notesfree 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.

ParameterDescription
datathe file content to upload
namethe file name, used to infer the content type when contentType is null
contentTypethe MIME type of the file, or null to infer it from the name
notesfree text notes to store against the asset
tagsthe 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.

ParameterDescription
datathe file content to upload
namethe file name, used to infer the content type when contentType is null
contentTypethe MIME type of the file, or null to infer it from the name
notesfree text notes to store against the asset
tagsthe asset type names to apply to the new asset, or null for none
relatedEntityIdthe 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.

ParameterDescription
datathe image content to upload
namethe file name
formatthe MIME type of the image
notesfree 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.

ParameterDescription
datathe image content to upload
namethe file name
formatthe MIME type of the image
notesfree text notes to store against the asset
assetTypesadditional 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.

ParameterDescription
datathe video content to upload
namethe file name
formatthe MIME type of the video
notesfree 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.

ParameterDescription
datathe video content to upload
namethe file name
formatthe MIME type of the video
notesfree text notes to store against the asset
assetTypesasset 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.

ParameterDescription
datathe file content to upload
namethe file name
formatthe MIME type of the file
notesfree 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.

ParameterDescription
datathe file content to upload
namethe file name
formatthe MIME type of the file
notesfree text notes to store against the asset
assetTypesasset 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.

ParameterDescription
datathe file content to upload
namethe file name
formatthe MIME type of the file
notesfree text notes to store against the asset
assetTypesasset type names to apply to the new asset, or null for none
relatedEntityIdthe id of the entity this asset relates to, or null for none

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.

ParameterDescription
querythe free text search query, split into terms
formatthe 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.

ParameterDescription
querythe free text search query, split into terms, or null/empty to match all assets
includedTypeNamesasset type names results must have, or null/empty for no restriction
excludedTypeNamesasset 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.

ParameterDescription
querythe free text search query, split into terms, or null/empty to match all assets
includedTypeNamesasset type names results must have, or null/empty for no restriction
excludedTypeNamesasset type names results must not have, or null/empty for no restriction
propsthe 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.

ParameterDescription
querythe search terms to match, or null/empty to match all assets
includedTypeNamesasset type names results must have, or null/empty for no restriction
excludedTypeNamesasset type names results must not have, or null/empty for no restriction
propsthe 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.

ParameterDescription
querythe search terms to match, or null/empty to match all assets
includedTypeNamesasset type names results must have, or null/empty for no restriction
excludedTypeNamesasset type names results must not have, or null/empty for no restriction
tenantIdthe id of the tenant organisation to search within
propsthe 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.

ParameterDescription
querythe free text search query, or blank to match all content
includedTypeNamescontent type names results must have, or empty for no restriction
excludedTypeNamescontent type names results must not have, or empty for no restriction
startPositionthe zero based index of the first result to return
pageSizethe maximum number of results to return
orderBythe field name to order results by
orderDirectionthe 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.

ParameterDescription
querythe free text search query, or blank to match all content
includedTypeNamescontent type names results must have, or empty for no restriction
excludedTypeNamescontent type names results must not have, or empty for no restriction
propsthe 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.

ParameterDescription
ctthe 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.

ParameterDescription
namethe name to give the new content item
ctthe 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.

ParameterDescription
ctthe content type to create an item of
rcthe form submission to read the name and field values from
currentUserIdthe 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.

ParameterDescription
ctthe content type to create an item of
namethe name to give the new content item
rcthe form submission to read field values from
currentUserIdthe 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.

ParameterDescription
ctthe content type to create an item of
namethe name to give the new content item
parametersraw field values keyed by field name, as submitted from a form
currentUserIdthe 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.

ParameterDescription
rcthe 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.

ParameterDescription
rcthe 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.

ParameterDescription
newItemthe asset to rename
newNamethe 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.

ParameterDescription
newItemthe content item to update
paramsraw 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.

ParameterDescription
newItemthe content item to update
fcthe 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.

ParameterDescription
newItemthe query asset to update
fcthe 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.

ParameterDescription
binaryAssetthe binary asset to update
inputStreamthe 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.

ParameterDescription
assetthe text asset to update
inputStreamthe 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.

ParameterDescription
textAssetthe text asset to update
fcthe form submission to read the name, format, text and notes from

find(String id)

Returns: Asset

Finds an asset by its unique id.

ParameterDescription
idthe asset's unique id

find(Relation r)

Returns: Asset

Finds the asset that a relation points to.

ParameterDescription
rthe 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.

ParameterDescription
fromthe asset whose relations are searched, or null
relationthe 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.

ParameterDescription
fromthe asset whose relations are searched
relationthe relation name to look for

findByName(String name)

Returns: Asset

Finds an asset by its name.

ParameterDescription
namethe asset name to look up

findContentType(String type)

Returns: ContentType

Finds a registered content type by name.

ParameterDescription
typethe 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.

ParameterDescription
namethe name of the new asset type
typethe 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.

ParameterDescription
assetthe 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.

ParameterDescription
assetthe content item to read the field value from
fieldDefthe 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.

ParameterDescription
assetthe content item to read the field value from, or null
fieldDefthe field definition to read, or null
langCodethe 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.

ParameterDescription
assetthe content item to render the field from
fieldDefthe 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.

ParameterDescription
assetthe content item the input is for
fieldDefthe 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.

ParameterDescription
assetthe binary asset to read
consumerthe 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.

ParameterDescription
assetthe binary asset to read
outthe 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.

ParameterDescription
assetthe asset to tag
assetTypeNamethe asset type name to apply
profileIdthe 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.

ParameterDescription
assetthe asset to untag
assetTypeNamethe asset type name to remove
profileIdthe 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.

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

ParameterDescription
currentUserthe user to check, or null
typesthe asset type names creation is being requested for, or null
relatedEntitythe entity the new asset would relate to, or null
currentWebsitethe 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).

ParameterDescription
userthe user to check
typethe 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.

ParameterDescription
assetthe 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.

ParameterDescription
atthe asset type to search for a matching controller method, or null
assetthe 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.

ParameterDescription
assetthe 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.

ParameterDescription
atthe 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.

ParameterDescription
assetIdsthe unique ids of the assets to delete

delete(Asset asset)

Returns: void

Deletes a single asset, firing the asset deleted event first.

ParameterDescription
assetthe 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.

ParameterDescription
querythe saved query to evaluate
contextcontextual data available to the query rules

evaluateAssetQuery(QueryAsset query)

Returns: List<Asset>

Evaluates a saved query with an empty context and no explicit ordering.

ParameterDescription
querythe 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.

ParameterDescription
querythe saved query to evaluate
orderFieldthe field name to order results by, or null for no explicit ordering
orderAscendingtrue 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.

ParameterDescription
querythe saved query to evaluate, or null
contextcontextual data available to the query rules
orderFieldthe field name to order results by, or null for no explicit ordering
orderAscendingtrue 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.

ParameterDescription
assetthe saved query to update
ruleAndTargetsthe 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.

ParameterDescription
assetthe 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.

ParameterDescription
isFromtrue to take the "from" asset of each relation, false to take the "to" asset
relationsthe relations to resolve

isNew(Asset asset)

Returns: boolean

Checks whether an asset has not yet been persisted.

ParameterDescription
assetthe 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.

ParameterDescription
newItemthe 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.

ParameterDescription
updatedItemthe 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.

ParameterDescription
assetthe 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.

ParameterDescription
assetthe text asset to read
langCodethe 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.

ParameterDescription
assetthe text asset the translation is for
langCodethe language code the translation is in
textthe 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.

ParameterDescription
assetthe asset to translate
createLangCodethe 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.

ParameterDescription
assetthe asset to find translations of

getCurrentTranslation(Asset asset)

Returns: Asset

Returns the translation of an asset for the currently selected language, if one exists.

ParameterDescription
assetthe 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.

ParameterDescription
defthe relation field definition specifying the target content type
assetthe 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.

ParameterDescription
assetthe content item to search field definitions for, or null
fieldNamethe 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.

ParameterDescription
baseTypethe 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.

ParameterDescription
cthe 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.

ParameterDescription
inthe 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.

ParameterDescription
assetthe 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.

ParameterDescription
assetthe video asset to find HLS streaming metadata for

findHlsPrimaries(String sourceVideoHash)

Returns: HlsPrimaryBean

Finds the HLS streaming metadata generated for a video content hash.

ParameterDescription
sourceVideoHashthe 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.

ParameterDescription
outthe 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.

ParameterDescription
videoAssetthe 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.

ParameterDescription
videoAssetthe video asset to generate streaming output for
doAsynctrue 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.

ParameterDescription
athe 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.

ParameterDescription
assetthe 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.

ParameterDescription
assetthe binary asset to deploy
mustPublishtrue 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.

ParameterDescription
assetsthe assets to publish

deployAssetToCdn(BinaryAsset asset, ContentDeliveryService foundCdn, Website cdnWebsite)

Returns: boolean

Deploys a single asset to the CDN, firing an invalidation immediately.

ParameterDescription
assetthe asset to publish
foundCdnthe CDN service to publish to
cdnWebsitethe 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.

ParameterDescription
assetthe asset to publish
foundCdnthe CDN service to publish to
cdnWebsitethe website associated with the CDN distribution
cdnPathsToInvalidateif non-null, CDN paths are collected here instead of invalidating immediately

copy(Asset asset)

Returns: Asset

Creates a duplicate of an asset.

ParameterDescription
assetthe asset to copy

getAssetTypes()

Returns: List<AssetType>

All asset types currently registered.

findAssetType(String typeName)

Returns: AssetType

Finds a registered asset type by name.

ParameterDescription
typeNamethe 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.

ParameterDescription
assetthe asset to update
relatedEntityIdthe id of the entity the asset relates to
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.