Last active
September 11, 2023 10:09
-
-
Save ksurendra/f34af635d1ef30b5378656a97bafce4a to your computer and use it in GitHub Desktop.
Get all properties of an Asset from AEM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Resource resource; | |
ValueMap mainProperties; | |
ValueMap assetMetadataProperties; | |
Resource metadataResource; | |
ValueMap jcrProperties; | |
Resource jcrdataResource; | |
ValueMap allProperties; | |
for (Hit hit : result.getHits()) { | |
//LOGGER.info("nHit path="+hit.getPath()+", title="+hit.getTitle()); resource = hit.getResource(); | |
if(null!=resource){ mainProperties = resource.getValueMap(); | |
// Add JCR Properties | |
jcrdataResource = resource.getChild("jcr:content"); | |
jcrProperties = ResourceUtil.getValueMap(jcrdataResource); | |
// Add Metadata properties | |
metadataResource = resource.getChild("jcr:content/metadata"); | |
assetMetadataProperties = ResourceUtil.getValueMap(metadataResource); | |
// Adding all together | |
allProperties = new ValueMapDecorator(new HashMap()); | |
allProperties.putAll(hit.getProperties()); | |
allProperties.putAll(mainProperties); // Includes jcr:created createdDate etc. | |
allProperties.put("jcr:path",hit.getPath()); //Add Path | |
allProperties.putAll(jcrProperties); | |
allProperties.putAll(assetMetadataProperties); | |
//LOGGER.debug("All Asset Properties="+new Gson().toJson(allProperties)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment