April 3, 2020
Estimated Post Reading Time ~

How to get an impersonated Resolver in CQ5/AEM?

It is very easy to get an impersonated resolver:

Try the below code. Just pass the user id and resourceResolverFactory instance.

private ResourceResolver getImpersonatedResolver(final String userId) {
try {
return resourceResolverFactory.getAdministrativeResourceResolver(Collections.singletonMap(ResourceResolverFactory.USER_IMPERSONATION, (Object) userId));
} catch (LoginException e) {
throw new RuntimeException(e);
}
}



By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.