On 25.04.2014, at 12:43, Alexander Klimetschek <[email protected]> wrote:

> Which is A LOT of boilerplate given there already is a clone() method. It is 
> not so much if using the USER_IMPERSONATION

Using USER_IMPERSONATION like this

            final ResourceResolver clonedResolver = resolver.clone(new 
HashMap<String, Object>() {{
                put(ResourceResolverFactory.USER_IMPERSONATION, 
resolver.getUserID());
            }});

does NOT work, as the JcrResourceProviderFactory tries to be clever and avoids 
self-impersonation [1]. It reuses the original session :(

[1] 
https://github.com/apache/sling/blob/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderFactory.java#L364

Cheers,
Alex

Reply via email to