Interface ContentResolverService
- All Known Implementing Classes:
DefaultContentResolver
,DefaultFilesystemContentResolver
Asset
by their URLs.
This service should be used when the actual digital content related to a Asset
needs to
be retrieved. Implementations should rely on a StorageProvider
to retrieve the location
of the resource, and then return a handle to stream that resource.
- Author:
- Samarth Dhruva (samarthd)
-
Method Summary
Modifier and TypeMethodDescriptiondefault Optional<org.springframework.core.io.Resource>
readResource
(String url, org.springframework.util.MultiValueMap<String, String> imageEffectsTags, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method will accept a URL and then return a handle to stream the resource from theStorageProvider
.readResourceWithMetadata
(@NonNull String url, org.springframework.util.MultiValueMap<String, String> imageEffectsTags, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method will accept a URL and then return a handle to stream the resource from theStorageProvider
.
-
Method Details
-
readResource
default Optional<org.springframework.core.io.Resource> readResource(@NonNull String url, @Nullable org.springframework.util.MultiValueMap<String, String> imageEffectsTags, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method will accept a URL and then return a handle to stream the resource from the
StorageProvider
.If the content is requested with certain effects applied, the method will search for a cached copy of the content with those effects applied. If no cached copy is found, then the base content is retrieved, the effects are applied to it, the modified version is cached in the storage provider, and then returned. Of course, if the base content is not found, this method will simply return an
Optional.empty()
.- Parameters:
url
- the URL of the digital content to fetchimageEffectsTags
- the image effects tags to apply to the content; a map of effects to their values.contextInfo
- context information surrounding sandboxing and multitenant state- Returns:
- an
Optional
containing theResource
, orOptional.empty()
if not found - Throws:
ImageOperationException
- - Thrown when an exception occurs applying the effects. This could occur when creating the new file, the thread performing the operation is interrupted, or some other reason.ResourceResolutionException
- if the new file with the applied effects can't be foundStorageException
- if an error occurred while trying to save the image to the file system.
-
readResourceWithMetadata
Optional<ResourceWithMetadata> readResourceWithMetadata(@NonNull @NonNull String url, @Nullable org.springframework.util.MultiValueMap<String, String> imageEffectsTags, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method will accept a URL and then return a handle to stream the resource from the
StorageProvider
.If the content is requested with certain effects applied, the method will search for a cached copy of the content with those effects applied. If no cached copy is found, then the base content is retrieved, the effects are applied to it, the modified version is cached in the storage provider, and then returned. Of course, if the base content is not found, this method will simply return an
Optional.empty()
.- Parameters:
url
- the URL of the digital content to fetchimageEffectsTags
- the image effects tags to apply to the content; a map of effects to their values.contextInfo
- context information surrounding sandboxing and multitenant state- Returns:
- an
Optional
containing theResourceWithMetadata
, orOptional.empty()
if not found - Throws:
ImageOperationException
- - Thrown when an exception occurs applying the effects. This could occur when creating the new file, the thread performing the operation is interrupted, or some other reason.ResourceResolutionException
- if the new file with the applied effects can't be foundStorageException
- if an error occurred while trying to save the image to the file system.
-