When writing rendering code, a commonly used shortcut is to do deep reads
to get properties from a child resource, like:
ValueMap vm = ResourceUtil.getValueMap(resource);
vm.get("jcr:content/jcr:title", "No title found");

While this works with jcr backed resources, this doesn't work in the
general case and the contract of a value map returned by a resource is to
just return the properties of the resource. In addition, the implementation
in the jcr resource bundle is wrong as it bypasses all resource mechanisms,
e.g. in the above case resource.getChild("jcr:content") might return a
resource from a different resource provider etc.
Adding the same code over and over again in each ValueMap implementation
doesn't look like a good solution either.

The simplest solution would be to enhance ResourceUtil.getValueMap() to
return a wrapper of the value map which allows deep reads.

Introducing a new concept, like a DeepValueMap (maybe with a better name)
are not very helpful as this would require to change all existing code.
However, it is safe to assume that existing code is using
ResourceUtil.getValueMap().

WDYT?

Regards
Carsten
-- 
Carsten Ziegeler
cziege...@apache.org

Reply via email to