public class DamUtil
extends java.lang.Object
| Constructor and Description |
|---|
DamUtil() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
assetToBinaryPath(java.lang.String path)
Translates the path of an asset to its congruent DAM binary path, by replacing the /content/dam path
prefix with /var/dam.
|
static java.lang.String |
binaryToAssetPath(java.lang.String path)
Translates the path of a DAM binary to its congruent asset path, by replacing the /var/dam path prefix
with /content/dam.
|
static java.util.List<java.lang.String> |
findExpiringAssets(Session session,
java.util.Calendar lowerBound,
java.util.Calendar upperBound)
Find all dam assets which are getting expired between lowerBound and upperBound.
|
static java.lang.String |
getThumbnailName(int width,
int height)
Returns the name of a thumbnail in the DAM thumbnail name format, respecting the given dimensions of the
thumbnail.
|
static java.lang.String |
getThumbnailName(int width,
int height,
java.lang.String[] selectors)
Behaves like
getThumbnailName(int, int). |
static java.lang.String |
getThumbnailName(ThumbnailConfig config)
Returns the expected rendition/thumbnail name based on the given thumbnail configuration.
|
static java.lang.String |
getValue(Node n,
java.lang.String name,
java.lang.String defaultValue)
Returns the single property value from the given node
n with
name. |
static boolean |
isAsset(Resource resource)
|
static boolean |
isRendition(Resource resource)
|
static boolean |
isSubAsset(Resource resource)
Indicates whether the given
resource is an Asset's sub-asset. |
static boolean |
isThumbnail(Node file)
This method determines whether the given
Node represents a thumbnail of an asset. |
static Asset |
resolveToAsset(Resource resource)
Checks whether the given
resource is an asset, and if not, travels upwards the resource hierarchy
until a resource is an asset. |
static void |
setModified(Asset asset,
java.lang.String user,
java.util.Calendar date)
This method updates the "last modified" information of the given
Asset. |
public static java.lang.String assetToBinaryPath(java.lang.String path)
null is
returned.
DamUtil.assetToBinaryPath("/content/dam/myfolder/test.jpg") = "/var/dam/myfolder/test.jpg"
DamUtil.assetToBinaryPath(null) = null
path - The path to translate.null if the given path is not a DAM asset path.DamConstants.MOUNTPOINT_BINARIES,
DamConstants.MOUNTPOINT_ASSETSpublic static java.lang.String binaryToAssetPath(java.lang.String path)
null is
returned.
DamUtil.binaryToAssetPath("/var/dam/myfolder/test.jpg") = "/content/dam/myfolder/test.jpg"
DamUtil.binaryToAssetPath(null) = null
path - The path to translate.null if the given path is not a DAM binary path.DamConstants.MOUNTPOINT_BINARIES,
DamConstants.MOUNTPOINT_ASSETSpublic static boolean isThumbnail(Node file)
Node represents a thumbnail of an asset.file - The node to check.true if the node represent's an asset's thumbnail, false otherwise.public static java.lang.String getThumbnailName(int width,
int height)
width of 100 and a height of 100 would return the thumbnail
name cq5dam.thumbnail.100.100.png. As a thumbnail represents a rendition of an Asset, the name can be used for easy retrieval of the thumbnail:
... final String thumbnailName = DamUtil.getThumbnailName(100, 100); final Resource thumbnail = asset.getRendition(thumbnailName); ...
width - The width of the thumbnail.height - The height of the thumbnail.public static java.lang.String getThumbnailName(ThumbnailConfig config)
config - The ThumbnailConfigRendition name.public static java.lang.String getThumbnailName(int width,
int height,
java.lang.String[] selectors)
getThumbnailName(int, int). Additionally and optionally a string array of selectors to be
added to the thumbnail name can be specified. E.g. providing width = 100, height = 100
and selectors = {"a", "b", "c"} would return the thumbnail name
cq5dam.thumbnail.100.100.a.b.c.png. Example:
...
final String[] selectors = {"a", "b", "c"};
final String thumbnailName = DamUtil.getThumbnailName(100, 100, selectors);
final Resource thumbnail = asset.getRendition(thumbnailName);
...
width - The width of the thumbnail.height - The height of the thumbnail.selectors - An array of selectors to be added. May be null (ignored).public static boolean isRendition(Resource resource)
Resource represents a Rendition of an Asset. The requirements are that given resource is stored within the
renditions folder of an asset and that it's node type is nt:file.resource - The resource to check.true if the resource is a rendition.public static boolean isAsset(Resource resource)
Resource represents a Asset. The requirements are
that the given resource is of node type dam:Asset.resource - The resource to check.true if the resource is an asset.public static boolean isSubAsset(Resource resource)
resource is an Asset's sub-asset.resource - The Resource to check.true if this asset is a sub-asset.public static Asset resolveToAsset(Resource resource)
resource is an asset, and if not, travels upwards the resource hierarchy
until a resource is an asset.resource - The resource to check.Asset or null if no asset was found.public static void setModified(Asset asset, java.lang.String user, java.util.Calendar date)
Asset.asset - The asset to update.user - The username of who updated the asset.date - The date/time the updated happened.public static java.util.List<java.lang.String> findExpiringAssets(Session session,
java.util.Calendar lowerBound,
java.util.Calendar upperBound)
throws RepositoryException
session - expiryDatePropName - the property on which asset expiration is computed.lowerBound - the lower bound of date where asset expiration is computed. If null it is not considered as
query criterionupperBound - the upper bound of date where asset expiration is computed. If null it is not considered as
query criterionRepositoryExceptionpublic static java.lang.String getValue(Node n,
java.lang.String name,
java.lang.String defaultValue)
throws RepositoryException
n with
name. If there is no single-valued property for the given
name, then the defaultValue is returned.n - a node.name - a property name.defaultValue - the default value.RepositoryException - if value cannot be retrieved