Skip to content

SampleResourceWrapper behaves differently than a JCR resource #56

@joerghoh

Description

@joerghoh

Today we encountered the problem, that the application behaved differently when called on a JCR resource than on wrapped resource (which is built according to the SampleResourceWrapper).

The application code looked like this:

ValueMap map = resource.adaptTo(ValueMap.class);
Date lastModified = map.get("cq:lastModified", Date.class);

When the resource is a JCR resource, a correct Date object is returned, if the Resource is a SampleResourceWrapper, null is returned (even if the property comes from the wrapped resource and is not injected by the wrapper).

It took us some time to track that back to SLING-6420 (which is likely to be part of AEM 6.3); and our solution was to change the ValueMapDecorator [1] to a CompositeValueMap, which provided the proper semantics.

So can you please adjust the sample?

[1] https://github.com/Adobe-Consulting-Services/acs-aem-samples/blob/master/bundle/src/main/java/com/adobe/acs/samples/resources/SampleResourceWrapper.java#L46

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions