Class ServletContentUrlResolver
java.lang.Object
com.broadleafcommerce.asset.jackson.ServletContentUrlResolver
- All Implemented Interfaces:
ContentUrlResolver
Implements
ContentUrlResolver
for web applications of type ConditionalOnWebApplication.Type.SERVLET
.- Author:
- Samarth Dhruva (samarthd)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionServletContentUrlResolver
(InternalAssetProperties internalAssetProperties, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptiongetContentUrl
(Asset asset) If theAsset.storageType
is internal, the content URL will be the result of prepending the necessary prefixes (like the content provider URL) to theAsset.url
.protected InternalAssetProperties
protected com.fasterxml.jackson.databind.ObjectMapper
-
Field Details
-
CONTEXT_REQUEST_PARAM
- See Also:
-
-
Constructor Details
-
ServletContentUrlResolver
public ServletContentUrlResolver(InternalAssetProperties internalAssetProperties, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
getContentUrl
If theAsset.storageType
is internal, the content URL will be the result of prepending the necessary prefixes (like the content provider URL) to theAsset.url
. For externalAsset.storageType
, the content URL will just be a duplication of the original url.Note: this serializer relies on
RequestContextHolder
to obtain information such as the context path, scheme, etc. If there is no request associated with the current thread,contentUrl
will just be a duplication of the original url.Note: since the
ContentResolverEndpoint
requires context information to properly locate the asset, the content URL will have the request parameter contextRequest containing tenant information appended to the URL based upon theAsset.contextState
.- Specified by:
getContentUrl
in interfaceContentUrlResolver
- Parameters:
asset
- the asset for which to create the content URL- Returns:
- a fully resolved content URL path that can be used to directly fetch the binary data
of the
asset
. Can be null ifAsset.getUrl()
is null. - Throws:
IllegalArgumentException
- if an internal asset is found to have a blank url
-
getInternalAssetProperties
-
getObjectMapper
@NonNull protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
-