Class ServletContentUrlResolver

java.lang.Object
com.broadleafcommerce.asset.jackson.ServletContentUrlResolver
All Implemented Interfaces:
ContentUrlResolver

public class ServletContentUrlResolver extends Object implements ContentUrlResolver
Implements ContentUrlResolver for web applications of type ConditionalOnWebApplication.Type.SERVLET.
Author:
Samarth Dhruva (samarthd)
  • Field Details

  • Constructor Details

    • ServletContentUrlResolver

      public ServletContentUrlResolver(InternalAssetProperties internalAssetProperties, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
  • Method Details

    • getContentUrl

      @Nullable public String getContentUrl(@NonNull Asset asset)
      If the Asset.storageType is internal, the content URL will be the result of prepending the necessary prefixes (like the content provider URL) to the Asset.url. For external Asset.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 the Asset.contextState.

      Specified by:
      getContentUrl in interface ContentUrlResolver
      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 if Asset.getUrl() is null.
      Throws:
      IllegalArgumentException - if an internal asset is found to have a blank url
    • getInternalAssetProperties

      @NonNull protected InternalAssetProperties getInternalAssetProperties()
    • getObjectMapper

      @NonNull protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()