How-to Retrieve All Properties Including Metadata Of An Asset From AEM


When we need to return all the properties of an Asset (or a Node, Asset is also a node), there is no single method that will return all the properties. We have to do this in a combination. This article details the steps.

Step-by-step guide

For each found result/node, we have to do the following:

  1. Get all the top level properties (Node root level). These include `jcr:created`, `jcr:createdBy`, etc.
  2. Get all `jcr:content` level properties. These include `cq:name`, `cq:lastModified`, etc
  3. Get all `jcr:content\metadata` level properties. These include `dc:title`, any custom metadata etc.
  4. You can add all these to another new `ValueMap` that can hold all the properties of a particular Node/Asset.

Below is a code snippet:


  1. `jcr:path` is not returned by any of the above. So i had to explicitly add it using `hit.getPath`
  2. The name of the node or Asset name can be pulled from `hit.getTitle()`. Ofcourse this is also returned as part of `cq:name`.
  3. There are other ways to get the properties as well. One aother way is to get the `Node` and retrieve the properties. `` has a method `getNode()` that returns a `java.jcr.Node` interface and you can use that get to fetch the properties.