Class Asset
- All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ContextStateAware
,Serializable
A Asset encapsulates information related to stored, digital content such as images, videos, or text files.
A Asset maps a stored file to an accessible URL
, maintains SEO data such as
alt text
and title
, and maintains audit data such as date uploaded
and the uploader
. Furthermore, Asset can be given
tags
to provide a means of designating special purposes for the asset, group otherwise
related assets such as "banners", or provide a label for some other arbitrary purpose.
Asset can represent externally stored files (such as a video on a 3rd-party video-sharing website like Vimeo or YouTube) or internally stored files (such as on the local filesystem).
- Author:
- Nathan Moore (nathanmoore).
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
boolean
Text that corresponds to the HTMLalt
attribute that should be used when this asset is rendered in a browser.Additional attributes of the asset.User who created this asset.com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState
A subset ofTracking
information to expose the context state for this object.If and only if thetype
isDefaultAssetType.EMBED
, this field holds the HTML to embed.For assets with an externalstorageType
, this field is required and names where the external asset is sourced from.The context ID of the folder in which this asset is placed.getId()
the context ID of this assetDate the file was last updated.Designate this asset to be used in a specificLocale
.MIME storageType of the file represented by this asset: image/png, image/jpeg, application/pdf, &c.long
getSize()
Size in bytes of the file represented by this asset.Added to provide a more human-readable way to displaysize
by appending the units.Defines where the digital content represented by this asset is stored.getTags()
Descriptive or identifying labels.getTitle()
Text that corresponds to the HTMLtitle
attribute that should be used when this asset is rendered in a browser.getType()
Describes the general type of the asset.Date the file was uploaded to create this asset.getUrl()
Location used to resolve this asset by callers using the service such as "/icon.png" for aninternal asset
or "https://www.youtube.com/watch?v=a1S2d3F4" forexternal asset
.int
hashCode()
void
setAltText
(String altText) Text that corresponds to the HTMLalt
attribute that should be used when this asset is rendered in a browser.void
setAttributes
(Map<String, Object> attributes) Additional attributes of the asset.void
User who created this asset.void
setContextState
(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState) A subset ofTracking
information to expose the context state for this object.void
setEmbedCode
(String embedCode) If and only if thetype
isDefaultAssetType.EMBED
, this field holds the HTML to embed.void
setExternalProvider
(String externalProvider) For assets with an externalstorageType
, this field is required and names where the external asset is sourced from.void
setFolderId
(String folderId) The context ID of the folder in which this asset is placed.void
the context ID of this assetvoid
setLastUpdatedDate
(Instant lastUpdatedDate) Date the file was last updated.void
Designate this asset to be used in a specificLocale
.void
setMimeType
(String mimeType) MIME storageType of the file represented by this asset: image/png, image/jpeg, application/pdf, &c.void
setSize
(long size) Size in bytes of the file represented by this asset.void
setSizeWithUnits
(String sizeWithUnits) void
setStorageType
(String storageType) Defines where the digital content represented by this asset is stored.void
setTags
(LinkedHashSet<String> tags) Descriptive or identifying labels.void
Text that corresponds to the HTMLtitle
attribute that should be used when this asset is rendered in a browser.void
Describes the general type of the asset.void
setUploadDate
(Instant uploadDate) Date the file was uploaded to create this asset.void
Location used to resolve this asset by callers using the service such as "/icon.png" for aninternal asset
or "https://www.youtube.com/watch?v=a1S2d3F4" forexternal asset
.toString()
-
Constructor Details
-
Asset
public Asset()
-
-
Method Details
-
getSizeWithUnits
Added to provide a more human-readable way to displaysize
by appending the units. For conciseness, this method also goes to the trouble of dynamically detecting the closest SI prefix that allows the size to be displayed without a decimal or thousands separator. Thus, if the size is 100,000,000 bytes, this would return 100MB.- Returns:
- the size of the digital content represented by this asset with SI abbreviation.
-
setSizeWithUnits
-
getId
the context ID of this asset- Returns:
- the id for this asset
-
getUrl
Location used to resolve this asset by callers using the service such as "/icon.png" for an
internal asset
or "https://www.youtube.com/watch?v=a1S2d3F4" forexternal asset
.Note: In the case of
internal asset
, this field is not the full path. The rest of the path is constructed using the prefixes defined inInternalAssetProperties
.Note that
embedCode
and this field can never both be present.- Returns:
- the url for this asset
- See Also:
-
getEmbedCode
If and only if thetype
isDefaultAssetType.EMBED
, this field holds the HTML to embed.Note that
url
and this field can never both be present.- Returns:
- the HTML to embed
-
getAltText
Text that corresponds to the HTMLalt
attribute that should be used when this asset is rendered in a browser. This is used as an alternative for screen-readers and as an SEO enhancement describing the asset.- Returns:
- the altText for this asset
-
getTitle
Text that corresponds to the HTMLtitle
attribute that should be used when this asset is rendered in a browser. This is used a tooltip or caption.- Returns:
- the title for this asset
-
getTags
Descriptive or identifying labels.
Tags can be used to:
- provide a means of designating special purposes for the asset
- group otherwise related assets such as "banners"
- provide a label for some other, arbitrary purpose
- Returns:
- the tags for this asset
-
getLocale
Designate this asset to be used in a specificLocale
.- Returns:
- the the locale this asset should be displayed in
-
getType
Describes the general type of the asset. This is used to determine how to render the asset on the frontend. For example, if the type isDefaultAssetType.IMAGE
, then the frontend will know to render it in an<img/>
tag.For assets with an external
storageType
, this field is required input. For internal assets, this is inferred from themimeType
during upload.- Returns:
- the general type of the asset
- See Also:
-
getExternalProvider
For assets with an externalstorageType
, this field is required and names where the external asset is sourced from. This field should be null for assets with an internalstorageType
.- Returns:
- the provider (for example, the name of the CDN) that is hosting the external asset
-
getMimeType
MIME storageType of the file represented by this asset: image/png, image/jpeg, application/pdf, &c.
See https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types for more info on MIME types
- Returns:
- the mimeType for this asset
-
getSize
public long getSize()Size in bytes of the file represented by this asset.- Returns:
- the size in bytes for this asset
-
getUploadDate
Date the file was uploaded to create this asset.- Returns:
- the uploadDate for this asset
-
getLastUpdatedDate
Date the file was last updated.- Returns:
- the lastUpdatedDate for this asset
-
getAuthor
User who created this asset.- Returns:
- the author for this asset
-
getStorageType
Defines where the digital content represented by this asset is stored. The default types areDefaultAssetStorageType.INTERNAL
andDefaultAssetStorageType.EXTERNAL
.- Returns:
- the storageType for this asset
- See Also:
-
getFolderId
The context ID of the folder in which this asset is placed. A asset with a nullfolderId
is not returned from folder content endpoints like/folder/{id}/assets
.- Returns:
- the context ID of the folder in which this asset is placed
-
getAttributes
Additional attributes of the asset.- Returns:
- additional attributes of the asset
-
getContextState
public com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState getContextState()A subset ofTracking
information to expose the context state for this object.- Specified by:
getContextState
in interfacecom.broadleafcommerce.data.tracking.core.ContextStateAware
- Returns:
- a subset of
Tracking
information to expose the context state for this object
-
setId
the context ID of this asset- Parameters:
id
- the value to set as the id for this asset
-
setUrl
Location used to resolve this asset by callers using the service such as "/icon.png" for an
internal asset
or "https://www.youtube.com/watch?v=a1S2d3F4" forexternal asset
.Note: In the case of
internal asset
, this field is not the full path. The rest of the path is constructed using the prefixes defined inInternalAssetProperties
.Note that
embedCode
and this field can never both be present.- Parameters:
url
- the value to set as the url for this asset- See Also:
-
setEmbedCode
If and only if thetype
isDefaultAssetType.EMBED
, this field holds the HTML to embed.Note that
url
and this field can never both be present.- Parameters:
embedCode
- the HTML to embed
-
setAltText
Text that corresponds to the HTMLalt
attribute that should be used when this asset is rendered in a browser. This is used as an alternative for screen-readers and as an SEO enhancement describing the asset.- Parameters:
altText
- the value to set as the altText for this asset
-
setTitle
Text that corresponds to the HTMLtitle
attribute that should be used when this asset is rendered in a browser. This is used a tooltip or caption.- Parameters:
title
- the value to set as the title for this asset
-
setTags
Descriptive or identifying labels.
Tags can be used to:
- provide a means of designating special purposes for the asset
- group otherwise related assets such as "banners"
- provide a label for some other, arbitrary purpose
- Parameters:
tags
- the value to set as the tags for this asset
-
setLocale
Designate this asset to be used in a specificLocale
.- Parameters:
locale
- which locale this asset should be displayed in
-
setType
Describes the general type of the asset. This is used to determine how to render the asset on the frontend. For example, if the type isDefaultAssetType.IMAGE
, then the frontend will know to render it in an<img/>
tag.For assets with an external
storageType
, this field is required input. For internal assets, this is inferred from themimeType
during upload.- Parameters:
type
- the general type of the asset- See Also:
-
setExternalProvider
For assets with an externalstorageType
, this field is required and names where the external asset is sourced from. This field should be null for assets with an internalstorageType
.- Parameters:
externalProvider
- the provider (for example, the name of the CDN) that is hosting the external asset
-
setMimeType
MIME storageType of the file represented by this asset: image/png, image/jpeg, application/pdf, &c.
See https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types for more info on MIME types
- Parameters:
mimeType
- the value to set as the mimeType for this asset
-
setSize
public void setSize(long size) Size in bytes of the file represented by this asset.- Parameters:
size
- the value to set as the size in bytes for this asset
-
setUploadDate
Date the file was uploaded to create this asset.- Parameters:
uploadDate
- the value to set as the uploadDate for this asset
-
setLastUpdatedDate
Date the file was last updated.- Parameters:
lastUpdatedDate
- the value to set as the lastUpdatedDate for this asset
-
setAuthor
User who created this asset.- Parameters:
author
- the value to set as the author for this asset
-
setStorageType
Defines where the digital content represented by this asset is stored. The default types areDefaultAssetStorageType.INTERNAL
andDefaultAssetStorageType.EXTERNAL
.- Parameters:
storageType
- the value to set as the storageType for this asset- See Also:
-
setFolderId
The context ID of the folder in which this asset is placed. A asset with a nullfolderId
is not returned from folder content endpoints like/folder/{id}/assets
.- Parameters:
folderId
- the context ID of the folder in which this asset is placed
-
setAttributes
Additional attributes of the asset.- Parameters:
attributes
- additional attributes of the asset
-
setContextState
public void setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState) A subset ofTracking
information to expose the context state for this object.- Specified by:
setContextState
in interfacecom.broadleafcommerce.data.tracking.core.ContextStateAware
- Parameters:
contextState
- a subset ofTracking
information to expose the context state for this object
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-