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 DefaultAssetType
determineAssetTypeFromMimeType
(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 generalDefaultAssetType
for use asAsset.getType()
.static String
getContextAwareAssetUrlPrefix
(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 String
getContextAwareUrl
(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 String
prependContextAwarePrefix
(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 theassetUrl
prepended 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 generalDefaultAssetType
for 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.UNKNOWN
if 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.url
as the first argument.- Parameters:
asset
- theAsset
for 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 theassetUrl
prepended with a tenant discriminated prefix based on theContextInfo
. This mostly delegates togetContextAwareAssetUrlPrefix(ContextInfo)
.If
ContextInfo
is null or has a null application ID and null tenant ID, the output will be{assetUrl}
. IfContextInfo
has a null application ID but present tenant ID, the output will be"/tenants/{tenantId}/" + {assetUrl}
. IfContextInfo
does 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
assetUrl
prepended 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
ContextInfo
is null or has a null application ID and null tenant ID, the output will be""
. IfContextInfo
has a null application ID but present tenant ID, the output will be"/tenants/{tenantId}"
. IfContextInfo
does 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
.