Use ASSET API how to iterate a parent node in AEM? | Community
Skip to main content
azhare3977562
Level 2
February 20, 2018
Solved

Use ASSET API how to iterate a parent node in AEM?

  • February 20, 2018
  • 3 replies
  • 3948 views

I have parent asset node inside the AEM CRXDE (/content/dam/parent). inside the parent node folder multiple child nodes are there .

Using Asset API how can i iterate the child nodes.?

After that i have to read/write properties.!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

Hemant_arora
Hemant_aroraAccepted solution
Level 8
February 20, 2018
azhare3977562
Level 2
February 20, 2018

Thanks :-) It is working but how to read/write the properties from asset.?

Hemant_arora
Level 8
February 21, 2018

Asset asset = resource.adaptTo(Asset.class);

String fileName = asset.getMetadataValue("dc:title");

if (fileName instanceof Object[]) {

Object[] titleArray = (Object[]) asset.getMetadata("dc:title");

fileName = (titleArray.length > 0) ? titleArray[0].toString() : "";

} else {

fileName = asset.getName();

}

Property property = asset.adaptTo(Node.class).getNode(JcrConstants.JCR_CONTENT + "/renditions/original/" + JcrConstants.JCR_CONTENT).getProperty(JcrConstants.JCR_DATA);

fileSize = property.getBinary().getSize();

String thumbnailPath = asset.adaptTo(Node.class).getNode(JcrConstants.JCR_CONTENT + "/renditions/" + "you/rendition/to/use").getPath();