Map<String, Object> param = new HashMap<String, Object>();
param.put(ResourceResolverFactory.SUBSERVICE, "datawrite");
ResourceResolver resolver = null;
try {
//Invoke the adaptTo method to create a Session used to create a QueryManager
resolver = resolverFactory.getServiceResourceResolver(param);
session = resolver.adaptTo(Session.class);
Note - see this article:
Querying Adobe Experience Manager 6 data using the Sling getServiceResourceResolver method
This code will not work in AEM 6.1 using a standard user,
Querying Adobe Experience Manager 6 data using the Sling getServiceResourceResolver method
This code will not work in AEM 6.1 using a standard user,
Note: All AEM 6.x HelpX Articles will be updated soon to use a System user to obtain a Session object from within an OSGi bundle.
To create a system user, perform these tasks:
Once created, you can extend permissions like a normal user using the AEM ACL functionality.
To create a system user, perform these tasks:
- Open http://localhost:4502/crx/explorer/index.jsp
- Login as admin
- Click User Administration
- Click Create System User
- Set the UserId
- Click Save
Once created, you can extend permissions like a normal user using the AEM ACL functionality.
Join the Adobe Experience Cloud Community
Join the Adobe Experience Cloud Community by clicking this banner
I (Scott Macdonald) am a Senior Digital Marketing Community Manager at Adobe Systems with 20 years in the high tech industry. I am also a programmer with knowledge in Java, JavaScript, C#,C++, HTML, XML and ActionScript. If you would like to see more CQ or other Adobe Digital Marketing end to end articles like this, then leave a comment and let me know what content you would like to see.
Twitter: Follow the Digital Marketing Customer Care team on Twitter @AdobeExpCare.
YouTube: Subscribe to the AEM Community Channel.
Twitter: Follow the Digital Marketing Customer Care team on Twitter @AdobeExpCare.