Class StorageUtils
java.lang.Object
com.broadleafcommerce.asset.service.support.StorageUtils
Deprecated, for removal: This API element is subject to removal in a future version.
Utility class containing helpful functionality pertaining to the storage and processing of
Assets by the StorageService.- Author:
- Samarth Dhruva (samarthd)
-
Method Summary
Modifier and TypeMethodDescriptionstatic DefaultAssetTypedetermineAssetTypeFromMimeType(String mimeType) Deprecated, for removal: This API element is subject to removal in a future version.Takes a valid mime type (for example, "image/png") and converts it to a generalDefaultAssetTypefor use asAsset.getType().static StringgetContextAwareAssetUrlPrefix(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated, for removal: This API element is subject to removal in a future version.Returns the tenant discrimination prefix that would be applied to an asset URL for the given context.static StringgetContextAwareUrl(Asset asset, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated, for removal: This API element is subject to removal in a future version.Returns theAsset.getUrl()prepended with a tenant discriminated prefix based on theContextInfo.static StringprependContextAwarePrefix(String assetUrl, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated, for removal: This API element is subject to removal in a future version.Returns theassetUrlprepended with a tenant discriminated prefix based on theContextInfo.
-
Method Details
-
determineAssetTypeFromMimeType
Deprecated, for removal: This API element is subject to removal in a future version.Takes a valid mime type (for example, "image/png") and converts it to a generalDefaultAssetTypefor use asAsset.getType().- Parameters:
mimeType- the mime type to examine and determine the general type for- Returns:
- the best guess for the general asset type, or
DefaultAssetType.UNKNOWNif it cannot be determined
-
getContextAwareUrl
public static String getContextAwareUrl(@NonNull Asset asset, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated, for removal: This API element is subject to removal in a future version.Returns theAsset.getUrl()prepended with a tenant discriminated prefix based on theContextInfo. This is purely a convenience method equivalent to callingprependContextAwarePrefix(String, ContextInfo)withAsset.urlas the first argument.- Parameters:
asset- theAssetfor which to create a context-aware URLcontextInfo- context information surrounding multitenant state- Returns:
- the
Asset.getUrl()prepended with a tenant discriminated prefix based on theContextInfo - See Also:
-
prependContextAwarePrefix
public static String prependContextAwarePrefix(@NonNull String assetUrl, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated, for removal: This API element is subject to removal in a future version.Returns theassetUrlprepended with a tenant discriminated prefix based on theContextInfo. This mostly delegates togetContextAwareAssetUrlPrefix(ContextInfo).If
ContextInfois null or has a null application ID and null tenant ID, the output will be{assetUrl}. IfContextInfohas a null application ID but present tenant ID, the output will be"/tenants/{tenantId}/" + {assetUrl}. IfContextInfodoes have a application ID, the output will be"/applications/{applicationId}/" + {assetUrl}.- Parameters:
assetUrl- the url to which the tenant-discriminated prefix should be prependedcontextInfo- context information surrounding multitenant state- Returns:
- the
assetUrlprepended with a tenant discriminated prefix based on theContextInfo - See Also:
-
getContextAwareAssetUrlPrefix
public static String getContextAwareAssetUrlPrefix(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated, for removal: This API element is subject to removal in a future version.Returns the tenant discrimination prefix that would be applied to an asset URL for the given context.If
ContextInfois null or has a null application ID and null tenant ID, the output will be"". IfContextInfohas a null application ID but present tenant ID, the output will be"/tenants/{tenantId}". IfContextInfodoes have a application ID, the output will be"/applications/{applicationId}".- Parameters:
contextInfo- context information surrounding multitenant state- Returns:
- the tenant discrimination prefix that would be applied to an asset URL for the given context
- See Also:
-
AssetStorageUtils.