Class InternalAssetProperties

java.lang.Object
com.broadleafcommerce.asset.autoconfigure.InternalAssetProperties

@ConfigurationProperties("broadleaf.asset.internal") public class InternalAssetProperties extends Object

Properties related to the Asset of storageType DefaultAssetStorageType.INTERNAL.

Consider this example Configuration:

  • broadleaf.asset.internal.prependServletContextPath = true (and the servlet context path for the asset service is /asset)
  • broadleaf.asset.internal.contentResolverEndpointPath = "/content"
  • broadleaf.asset.internal.prependContentResolverEndpointPath = true
  • broadleaf.asset.internal.contentProviderUrlPrefix = "https://mycompany.cloudfrountcdn.com"
  • And the CloudFront CDN has configured its "origin server" as https://my-microservices.server.com

Assuming the above configuration, when the browser requests the primary image for Product 1, the asset service returns a asset with the url https://mycompany.cloudfrountcdn.com/asset/content/product-1-primary.png, i.e., contentProviderUrlPrefix/servletContextPath/contentResolverEndpointPath/asset-url

Alternatively, the origin server could be https://my-microservices.server.com/asset/content, meaning that broadleaf.asset.internal.prependServletContextPath and broadleaf.asset.internal.prependContentResolverEndpointPath should both be false. The asset url would then be returned as https://mycompany.cloudfrountcdn.com/product-1-primary.png, i.e., contentProviderUrlPrefix/asset-url

Finally, consider if there was no CDN and broadleaf.asset.internal.contentProviderUrlPrefix = null. The Asset url would then be returned as https://my-microservices.server.com/asset/content/product-1-primary.png, i.e., servletUrl/contentResolverEndpointPath/asset-url.

Author:
Nathan Moore (nathanmoore).
  • Constructor Details

    • InternalAssetProperties

      public InternalAssetProperties()
  • Method Details

    • setContentResolverEndpointPath

      public void setContentResolverEndpointPath(String contentResolverEndpointPath)
    • isPrependRequestContextPath

      public boolean isPrependRequestContextPath()
      Determines whether to prepend the request context path to the asset's URL (Asset#url) when the API is generating the "contentUrl" field for internal assets (DefaultAssetStorageType#INTERNAL).

      This property can be useful if the content resolution endpoint in the asset service itself is behind a gateway or load-balancer with a particular request context path (e.g., "/api"), but there's a CDN configured and there is a desire to not have the request context path in the CDN URL. In this scenario, "prependRequestContextPath" would be set to false, and instead the CDN's origin server configuration would have the request context path.

      This property is respected regardless of whether the "contentProviderUrlPrefix" is blank.

      The request context path will go immediately after the "contentProviderUrlPrefix" (if it's enabled).

      Format:

      contentProviderUrlPrefix[/requestContextPath][/servletContextPath[/contentResolverEndpointPath]]

    • isPrependServletContextPath

      public boolean isPrependServletContextPath()

      If "contentProviderUrlPrefix" is not blank, then this property determines whether to also prepend the servlet's context path (e.g., "/asset") to the asset's URL (Asset#url) when the API is generating the "contentUrl" field for internal assets (DefaultAssetStorageType#INTERNAL). This goes after the "contentProviderUrlPrefix", after the request context path if enabled via "prependRequestContextPath", and before the "contentResolverEndpointPath" if enabled via "prependContentResolverEndpointPath". Default is true.

      Format:

      contentProviderUrlPrefix[/requestContextPath][/servletContextPath[/contentResolverEndpointPath]]

      Set this to false if using a CDN and able to append the servlet context path to the CDN's origin server URL.

    • getContentResolverEndpointPath

      public String getContentResolverEndpointPath()

      Defines the relative path of the endpoint to use to retrieve the actual digital content, as opposed to retrieving the Asset that represents it. Should start with a "/" but not end in one.

      If using a CDN, this should be appended to its origin server URL.

      Note that it is not necessary to append the servlet context path to this value. If needed, set "prependServletContextPath" to true.
    • isPrependContentResolverEndpointPath

      public boolean isPrependContentResolverEndpointPath()

      If "contentProviderUrlPrefix" is not blank, then this property determines whether to also prepend the "contentResolverEndpointPath" to the asset's URL (Asset#url) when the API is generating the "contentUrl" field for internal assets (DefaultAssetStorageType#INTERNAL). This will go after the "contentProviderUrlPrefix" and, if enabled via "prependServletContextPath", after the servlet's context path. Default is true.

      Format:

      contentProviderUrlPrefix[/requestContextPath][/servletContextPath[/contentResolverEndpointPath]]

      Set this to false if using a CDN and able to append "contentResolverEndpointPath" to the CDN's origin server URL.

    • getContentProviderUrlPrefix

      @Nullable public String getContentProviderUrlPrefix()

      Prefix that will be added to the asset's URL (Asset#url) when the API is generating the "contentUrl" field for internal assets (DefaultAssetStorageType#INTERNAL). This is useful for applications that have a separate image domain or use a CDN to render images. It also works well with CMS's that own the image part of your domain CNAME. Should not end in a "/".

      This would usually be something like "https://my.cdn.com". Then, in the CDN's configuration, the origin server would point to the BLC endpoint configured by "contentResolverEndpointPath". However, if left blank, the servlet URL (i.e., request.scheme + request.domain + request.port + request.contextPath: "https://my-microservices.server.com/asset") and "contentResolverEndpointPath" will be prefixed instead.

      Note that it is recommended to use a CDN.
    • getResourceNamesToIgnore

      public Set<String> getResourceNamesToIgnore()
      Set of resource names to ignore when uploading. This provides a way to ignore or reserve specific names (e.g., ".DS_Store" on Macs). If a resource is uploaded and its name starts with or equals one of these values, then it will be skipped during the upload process.

      The default values are initialized in the InternalAssetProperties no-args constructor.

    • getMaxIndividualAssetSize

      public org.springframework.util.unit.DataSize getMaxIndividualAssetSize()
      The maximum file size an individual asset can have. This restriction is applied to all items, whether they are uploaded individually or as part of a zip file. While "spring.servlet.multipart.max-file-size" and "spring.servlet.multipart.max-request-size" control the size validations at the level of the servlet container, this value represents a more fine-grained limit enforced during the upload processing flow within the storage service. To remain meaningful, this value should be less than the Spring multipart properties.
    • getMaxZipFileSize

      public org.springframework.util.unit.DataSize getMaxZipFileSize()
      The maximum file size a zip file (sent in multi-upload requests) can have. This is different from the limits on individual asset size. While "spring.servlet.multipart.max-file-size" and "spring.servlet.multipart.max-request-size" control the size validations at the level of the servlet container, this value represents a more fine-grained limit enforced during the upload processing flow within the storage service. To remain meaningful, this value should be less than the Spring multipart properties.
    • isStoreZipFileOnProvider

      public boolean isStoreZipFileOnProvider()
      In multi-upload requests, the zip file's contents are always extracted and stored on the provider. This property determines whether the zip file itself is also stored on the provider. This can be useful for support/debugging scenarios where the zip gets uploaded successfully but undergoes a problem with extraction.
    • getStorageProvider

      public InternalAssetProperties.StorageProvider getStorageProvider()
    • getBrowserAssetCaching

      public InternalAssetProperties.BrowserCacheProperties getBrowserAssetCaching()
    • setPrependRequestContextPath

      public void setPrependRequestContextPath(boolean prependRequestContextPath)
      Determines whether to prepend the request context path to the asset's URL (Asset#url) when the API is generating the "contentUrl" field for internal assets (DefaultAssetStorageType#INTERNAL).

      This property can be useful if the content resolution endpoint in the asset service itself is behind a gateway or load-balancer with a particular request context path (e.g., "/api"), but there's a CDN configured and there is a desire to not have the request context path in the CDN URL. In this scenario, "prependRequestContextPath" would be set to false, and instead the CDN's origin server configuration would have the request context path.

      This property is respected regardless of whether the "contentProviderUrlPrefix" is blank.

      The request context path will go immediately after the "contentProviderUrlPrefix" (if it's enabled).

      Format:

      contentProviderUrlPrefix[/requestContextPath][/servletContextPath[/contentResolverEndpointPath]]

    • setPrependServletContextPath

      public void setPrependServletContextPath(boolean prependServletContextPath)

      If "contentProviderUrlPrefix" is not blank, then this property determines whether to also prepend the servlet's context path (e.g., "/asset") to the asset's URL (Asset#url) when the API is generating the "contentUrl" field for internal assets (DefaultAssetStorageType#INTERNAL). This goes after the "contentProviderUrlPrefix", after the request context path if enabled via "prependRequestContextPath", and before the "contentResolverEndpointPath" if enabled via "prependContentResolverEndpointPath". Default is true.

      Format:

      contentProviderUrlPrefix[/requestContextPath][/servletContextPath[/contentResolverEndpointPath]]

      Set this to false if using a CDN and able to append the servlet context path to the CDN's origin server URL.

    • setPrependContentResolverEndpointPath

      public void setPrependContentResolverEndpointPath(boolean prependContentResolverEndpointPath)

      If "contentProviderUrlPrefix" is not blank, then this property determines whether to also prepend the "contentResolverEndpointPath" to the asset's URL (Asset#url) when the API is generating the "contentUrl" field for internal assets (DefaultAssetStorageType#INTERNAL). This will go after the "contentProviderUrlPrefix" and, if enabled via "prependServletContextPath", after the servlet's context path. Default is true.

      Format:

      contentProviderUrlPrefix[/requestContextPath][/servletContextPath[/contentResolverEndpointPath]]

      Set this to false if using a CDN and able to append "contentResolverEndpointPath" to the CDN's origin server URL.

    • setContentProviderUrlPrefix

      public void setContentProviderUrlPrefix(@Nullable String contentProviderUrlPrefix)

      Prefix that will be added to the asset's URL (Asset#url) when the API is generating the "contentUrl" field for internal assets (DefaultAssetStorageType#INTERNAL). This is useful for applications that have a separate image domain or use a CDN to render images. It also works well with CMS's that own the image part of your domain CNAME. Should not end in a "/".

      This would usually be something like "https://my.cdn.com". Then, in the CDN's configuration, the origin server would point to the BLC endpoint configured by "contentResolverEndpointPath". However, if left blank, the servlet URL (i.e., request.scheme + request.domain + request.port + request.contextPath: "https://my-microservices.server.com/asset") and "contentResolverEndpointPath" will be prefixed instead.

      Note that it is recommended to use a CDN.
    • setResourceNamesToIgnore

      public void setResourceNamesToIgnore(Set<String> resourceNamesToIgnore)
      Set of resource names to ignore when uploading. This provides a way to ignore or reserve specific names (e.g., ".DS_Store" on Macs). If a resource is uploaded and its name starts with or equals one of these values, then it will be skipped during the upload process.

      The default values are initialized in the InternalAssetProperties no-args constructor.

    • setMaxIndividualAssetSize

      public void setMaxIndividualAssetSize(org.springframework.util.unit.DataSize maxIndividualAssetSize)
      The maximum file size an individual asset can have. This restriction is applied to all items, whether they are uploaded individually or as part of a zip file. While "spring.servlet.multipart.max-file-size" and "spring.servlet.multipart.max-request-size" control the size validations at the level of the servlet container, this value represents a more fine-grained limit enforced during the upload processing flow within the storage service. To remain meaningful, this value should be less than the Spring multipart properties.
    • setMaxZipFileSize

      public void setMaxZipFileSize(org.springframework.util.unit.DataSize maxZipFileSize)
      The maximum file size a zip file (sent in multi-upload requests) can have. This is different from the limits on individual asset size. While "spring.servlet.multipart.max-file-size" and "spring.servlet.multipart.max-request-size" control the size validations at the level of the servlet container, this value represents a more fine-grained limit enforced during the upload processing flow within the storage service. To remain meaningful, this value should be less than the Spring multipart properties.
    • setStoreZipFileOnProvider

      public void setStoreZipFileOnProvider(boolean storeZipFileOnProvider)
      In multi-upload requests, the zip file's contents are always extracted and stored on the provider. This property determines whether the zip file itself is also stored on the provider. This can be useful for support/debugging scenarios where the zip gets uploaded successfully but undergoes a problem with extraction.
    • setStorageProvider

      public void setStorageProvider(InternalAssetProperties.StorageProvider storageProvider)
    • setBrowserAssetCaching

      public void setBrowserAssetCaching(InternalAssetProperties.BrowserCacheProperties browserAssetCaching)
    • toString

      public String toString()
      Overrides:
      toString in class Object