Wednesday, 12 April 2017

Get Resource Resolver Factory in AEM 6.0


@Reference
private ResourceResolverFactory resolverFactory;

private static final String SUBSERVICE_NAME = "publishContent";

private final Map<String, Object> resourceResolverAuthentication = new HashMap<>();
resourceResolverAuthentication.put(ResourceResolverFactory.SUBSERVICE, SUBSERVICE_NAME);

ResourceResolver resourceResolver = getResourceResolver(resourceResolverAuthentication);

protected ResourceResolver getResourceResolver(final Map<String, Object> resourceResolverAuthentication) {
                LOGGER.debug("Getting resource resolver for [{}]", resourceResolverAuthentication.get(ResourceResolverFactory.SUBSERVICE));
                try {
                                return resolverFactory.getServiceResourceResolver(resourceResolverAuthentication);
                } catch (LoginException le) {
                                LOGGER.error("Unable to get resource resolver for service [{}]", resourceResolverAuthentication.get(ResourceResolverFactory.SUBSERVICE),le);
                                return null;
                }
}

com.flip.geometrixx-bundle:publishContent =publish_content(username)
com.adobe.cq.social.cq-social-group:user-admin=admin

/apps/geometrixx/configs/config.author/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl

No comments:

Post a Comment