Search code examples
javaadobeaemsling

Uploading a xml file into the AEM DAM


I want to upload a xml file into the AEM DAM. The xml file is sitemap.xml which I read using InputStream. But how do I write ResourceResolver ? ResourceResolver resourceResolver = resolverFactory.getAdministrativeResourceResolver(null) is deprecated now. I am following this tutorial but facing this resource resolver problem. What will be the correct syntax ?


Solution

  • The method resolverFactory.getAdministrativeResourceResolver() is deprecated for security reasons. This gave you an admin-session without any permission checking.

    It is replaced by resolverFactory.getServiceResourceResolver(). This gives you a normal session with a pre-configured user. To configure it, go to the admin console (e.g. http://localhost:4502/system/console/configMgr ) and find the settings for Apache Sling Service User Mapper Service.

    For your tuturial it is fair enough, just to use the admin user for your Bundle as service user.

    Also look at the Adobe documentation for this issue: https://helpx.adobe.com/experience-manager/6-3/sites/administering/using/security-service-users.html