Hi @Imperfecto,
Unfortunately, you are right - the ContentFragment
interface from the AEM Content Fragment Core API (com.adobe.cq.dam.cfm.ContentFragment
) does not expose the ETag directly, and there’s no out-of-the-box method in the public Java APIs to retrieve an ETag the same way the HTTP API does.
Here are some possible workarounds - not perfect, but might help depending on your use case:
1. AEM typically calculates ETags using internal logic based on the last modification timestamp or binary checksum.
If your purpose is to do change detection, you might simulate your own ETag by hashing:
-
jcr:lastModified
-
Fragment element values
-
Metadata properties
Resource cfResource = resolver.getResource("/content/dam/your/fragment/path");
ValueMap vm = cfResource.getValueMap();
Calendar lastModified = vm.get("jcr:lastModified", Calendar.class);
Generate an MD5/SHA hash of those values - that can act as a pseudo-ETag.
2. If you're trying to know when something changed, and not necessarily retrieve the ETag itself, you can set up a ResourceChangeListener
on the /content/dam
path to detect changes to fragments, and cache/track accordingly.
hope that helps!
Santosh Sai

