public class DamUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
LIVEFYRE_ID |
static java.lang.String |
LIVEFYRE_THUMBNAIL |
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.Map<java.lang.String,Pair<java.lang.String,java.lang.Integer>> |
buildEntryDepthMap(SlingScriptHelper sling)
This method creates a Map containing list of asset paths pending in agent queues
|
static boolean |
checkforAIFile(Asset asset) |
static Node |
createEmptyArchiveNode(Resource configResource,
java.lang.String name,
Session serviceSession)
Deprecated.
|
static boolean |
expiryStatus(Asset asset) |
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 |
findRelativePathOfAssetNode(Node assetNode,
java.lang.String assetsRoot)
Obtain Asset's path relative to specified Asset's root
|
static Node |
getApplicableProfile(Asset asset,
java.lang.String profileType,
Session session)
Get a specific Processing profile which may be applied to an asset
|
static Node |
getApplicableProfile(Resource resource,
java.lang.String profileType,
Session session)
Get a specific Processing profile which may be applied to an asset
|
static java.lang.String |
getAppliedProcessingProfilePath(Asset asset)
Deprecated.
|
static AssetCache |
getAssetCache()
Get an instance of
AssetCache for access to cached rendition contents and
aggregated InputStream and temporary File cleanups. |
static Asset |
getAssetFromID(ResourceResolver resolver,
java.lang.String id)
Obtain
Asset provided the jcr:uuid |
static Asset |
getAssetFromMetaRes(Resource resource)
Returns
Asset for the dam:asset/jcr:content/metadata resource
else returns null. |
static java.util.Iterator<Asset> |
getAssets(Resource res)
Returns an iterator to all the assets contained in or represented by the resource.
|
static Rendition |
getBestFitFPORendition(Asset asset,
java.lang.String[] renditionPreferenceList) |
static Rendition |
getBestFitRendition(int width,
java.util.List<Rendition> renditions)
It iterates all renditions available and find the closest (preferably higher side) rendition and return the same.
|
static java.util.Calendar |
getExpiryTime(Asset asset) |
static java.awt.Dimension |
getImageDimension(java.io.InputStream is,
java.lang.String filename)
getImageDimension : To get actual width and height of the rendition or image for proper UI rendering of
thumbnails , earlier new Layer () API was being used which was inefficient.
|
static java.awt.Dimension |
getImageDimension(Rendition rendition)
getImageDimension : NUI To get actual width and height of the rendition or image for proper UI rendering of
thumbnails , earlier new Layer () API was being used which was inefficient.
|
static <T> T |
getInheritedProperty(java.lang.String property,
Resource resource,
T defaultValue)
This method searches for the property in the provided contentPath
resource.
|
static Asset |
getParentAsset(Resource resource) |
static java.util.List<ResourceCollection> |
getReferencedCollections(Resource resource) |
static java.util.List<Asset> |
getReferencedSubAssets(Resource resource) |
static java.util.Collection<Asset> |
getRefererAssets(ResourceResolver resolver,
java.lang.String path) |
static java.util.Collection<Asset> |
getSubAssets(Resource resource) |
static java.lang.String |
getTenantAssetsRoot(Resource resource)
Obtain Tenant Asset's root for specified Sling resource
|
static java.lang.String |
getTenantAssetsRoot(ResourceResolver resolver)
Obtain Tenant Asset's root for specified ResourceResolver
|
static java.lang.String |
getTenantAssetsRoot(ResourceResolver resolver,
java.lang.String assetPath)
Obtain Tenant Asset's root for specified asset path and ResourceResolver
This returns the tenant for the session associated with the resource resolver,
not the tenant associated with the asset if provided
assetPath
can't be resolved to an Asset |
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 |
getUserCollectionsPath(ResourceResolver resolver)
Obtain collection path for specified tenant and user.
|
static java.lang.String |
getValidFileName(java.lang.String name)
This method determines whether the file name contains special characters and replaces them
with underscore ("_")
|
static java.lang.String |
getValidFolderName(java.lang.String name)
This method determines whether the folder name contains special characters and replaces them
with underscore ("_")
|
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 |
isCollection(Resource resource)
Checks if given resource represents a collection.
|
static boolean |
isExpiredAsset(Asset asset)
Returns whether the asset has expired.
|
static boolean |
isExpiredAsset(Resource resource)
Returns whether the resource has expired.
|
static boolean |
isExpiredSubAsset(Resource resource)
Returns whether the resource has any subasset which has expired.
|
static boolean |
isFrozenNode(Resource resource)
Checks whether the give
Resource represents a frozen node. |
static boolean |
isImage(Asset asset)
To check weather asset falls under Image category.
|
static boolean |
isImage(java.lang.String mimeType)
To check whether given mime type is an image mime type.
|
static boolean |
isInRunningWorkflow(Resource resource)
This function determines if an asset has its
DamConstants.DAM_ASSET_STATE property is set to
DamConstants.DAM_ASSET_STATE_PROCESSING . |
static boolean |
isLivefyreFragment(Resource resource)
This function determines if an asset is livefyre asset.
|
static boolean |
isMetadataRes(Resource resource)
Returns true if
Asset can be adapted from
dam:asset/jcr:content/metadata resource else returns false. |
static boolean |
isPublic(Resource resource)
Checks if a given resource is readable by the tenant specific group.
|
static boolean |
isRendition(Resource resource)
|
static boolean |
isSmartCollection(Resource resource)
Checks if given resource represent a smart collection
|
static boolean |
isSubAsset(Resource resource)
Indicates whether the given
resource is an Asset 's sub-asset. |
static boolean |
isThreeD(Asset asset)
To check weather asset falls under ThreeD category (Dimensional 3D asset).
|
static boolean |
isThumbnail(Node file)
This method determines whether the given
Node represents a thumbnail of an asset. |
static boolean |
isValid(Asset asset)
Checks if the asset is valid.
|
static boolean |
isVideo(Asset asset)
To check weather asset falls under Video category.
|
static boolean |
isZipTypeAsset(Asset asset)
This method determines whether the provided asset is actually a zip asset or not
|
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 . |
static Node |
validateFolderNode(java.lang.String path,
Session serviceSession) |
public static final java.lang.String LIVEFYRE_ID
public static final java.lang.String LIVEFYRE_THUMBNAIL
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_ASSETS
public 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_ASSETS
public 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.util.Map<java.lang.String,Pair<java.lang.String,java.lang.Integer>> buildEntryDepthMap(SlingScriptHelper sling)
sling
- public static java.lang.String getValidFolderName(java.lang.String name)
public static java.lang.String getValidFileName(java.lang.String name)
public static boolean isZipTypeAsset(Asset asset)
asset
- the asset to checkpublic 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 ThumbnailConfig
Rendition
name.public static Node validateFolderNode(java.lang.String path, Session serviceSession) throws RepositoryException
RepositoryException
@Deprecated public static Node createEmptyArchiveNode(Resource configResource, java.lang.String name, Session serviceSession) throws RepositoryException
RepositoryException
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 isMetadataRes(Resource resource)
Asset
can be adapted from
dam:asset/jcr:content/metadata resource else returns false.public static Asset getAssetFromMetaRes(Resource resource)
Asset
for the dam:asset/jcr:content/metadata resource
else returns null.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 isFrozenNode(Resource resource)
Resource
represents a frozen node. The requirements are
that the given resource
is of node type nt:frozenNode.resource
- The resource to checktrue
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
- 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 criterionRepositoryException
public static boolean isExpiredAsset(Asset asset)
asset
- public static boolean isExpiredAsset(Resource resource)
resource
- public static boolean isExpiredSubAsset(Resource resource)
resource
- public 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 retrievedpublic static boolean isImage(Asset asset)
asset
- public static boolean isImage(java.lang.String mimeType)
mimeType
- public static boolean isThreeD(Asset asset)
asset
- public static boolean isVideo(Asset asset)
asset
- public static boolean isSmartCollection(Resource resource)
resource
- an instance of Resource
true
if resource
represents a smart collection
false
if resource
does not represents a smart collectionpublic static boolean isCollection(Resource resource)
resource
- an instance of Resource
public static boolean isPublic(Resource resource) throws RepositoryException
resource
- DAM resource like collection, snippetRepositoryException
- Error reading permissionspublic static Node getApplicableProfile(Asset asset, java.lang.String profileType, Session session)
asset
- The asset we get from payload of DamUpdateAsset WorkflowprofileType
- The type of profile to get (metadata/video/image)session
- To retrieve nodes from JCRpublic static Node getApplicableProfile(Resource resource, java.lang.String profileType, Session session)
resource
- The resource we get from payload of DamUpdateAsset WorkflowprofileType
- The type of profile to get (metadata/video/image)session
- To retrieve nodes from JCR@Deprecated public static java.lang.String getAppliedProcessingProfilePath(Asset asset)
public static java.util.Iterator<Asset> getAssets(Resource res)
ResourceCollection
, then all its member resources are consulted and navigated recursively if any of the member
represent folder or ResourceCollection
.
If the resource represents an asset itself, an iterator of single item i.e. Collections.singletonList(res.adaptTo(Asset.class)).iterator();public static boolean checkforAIFile(Asset asset)
public static Rendition getBestFitRendition(int width, java.util.List<Rendition> renditions)
width
- renditions
- public static Rendition getBestFitFPORendition(Asset asset, java.lang.String[] renditionPreferenceList)
asset
- The asset whose best fit fpo rendition is soughtrenditionPreferenceList
- The list of renditions in order of preferencepublic static java.awt.Dimension getImageDimension(java.io.InputStream is, java.lang.String filename)
public static java.awt.Dimension getImageDimension(Rendition rendition)
public static boolean expiryStatus(Asset asset)
public static java.util.List<Asset> getReferencedSubAssets(Resource resource)
public static java.util.List<ResourceCollection> getReferencedCollections(Resource resource)
public static java.util.Collection<Asset> getRefererAssets(ResourceResolver resolver, java.lang.String path)
public static java.util.Calendar getExpiryTime(Asset asset)
public static boolean isValid(Asset asset) throws RepositoryException
true
if the page is valid; false
otherwise.RepositoryException
public static java.lang.String getTenantAssetsRoot(ResourceResolver resolver)
public static java.lang.String getTenantAssetsRoot(ResourceResolver resolver, java.lang.String assetPath)
assetPath
can't be resolved to an Assetpublic static java.lang.String getTenantAssetsRoot(Resource resource)
public static java.lang.String getUserCollectionsPath(ResourceResolver resolver)
resolver
- Adaptable for tenant and userpublic static Asset getAssetFromID(ResourceResolver resolver, java.lang.String id) throws RepositoryException
Asset
provided the jcr:uuid
Asset
, or null if asset with specified ID wasn't foundRepositoryException
public static java.lang.String findRelativePathOfAssetNode(Node assetNode, java.lang.String assetsRoot) throws RepositoryException
DamConstants.DAM_ASSET_RELATIVE_PATH
RepositoryException
public static <T> T getInheritedProperty(java.lang.String property, Resource resource, T defaultValue)
property
- the property user is looking for.resource
- the resource representing the path where the property has to
be searcheddefaultValue
- public static boolean isInRunningWorkflow(Resource resource)
DamConstants.DAM_ASSET_STATE
property is set to
DamConstants.DAM_ASSET_STATE_PROCESSING
. Presently this returns true only if in DAM update
asset workflow.resource
- the resource to checkDamConstants.DAM_ASSET_STATE
property is set to DamConstants.DAM_ASSET_STATE_PROCESSING
false otherwisepublic static AssetCache getAssetCache()
AssetCache
for access to cached rendition contents and
aggregated InputStream
and temporary File
cleanups.public static boolean isLivefyreFragment(Resource resource)
resource
- the resource to checkLIVEFYRE_ID
property is avaliable,
false otherwiseCopyright © 2010 - 2020 Adobe. All Rights Reserved