Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

automating multiple digital asset upload

Avatar

Level 2

We are using AEM 6.1. 

We tried the solution based on https://helpx.adobe.com/experience-manager/using/multiple-digital-assets.html

We customized HandleFile.java a bit (just one line). It is attached here. HandleFile.java has a method writetoClintLib and it fails with NullPointerException at ResourceResolver resourceResolver = resolverFactory.getAdministrativeResourceResolver(null);

Seems like injection for ResourceResolverFactory is not working, but not sure why.

1 Accepted Solution

Avatar

Correct answer by
Administrator

Adding to what Scott has mentioned, it is not good practice to use getAdministrativeResourceResolver method. It has been depricated from ResourceResolverFactory.

Please have a look at the link, it will answer all your questions :-

Link:- http://www.accunitysoft.com/resourceresolver-object-in-aem6-16-0-sling-services/

//Use getServiceResourceResolver()

Here step by step everythig is mentioned, how to use it. And how to use it in AEM 6 and AEM 6.1.

 

Depricated Info :- https://sling.apache.org/apidocs/sling7/org/apache/sling/api/resource/ResourceResolverFactory.html#g...

Forum Link:-http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage...

I hope this would help you.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

View solution in original post

7 Replies

Avatar

Level 10

As shown at the start of the article - this article was tested on CQ 5.5, 5.6, and 6.

I will test on 6.1 on tues and see if it works. I suspect that on 6.1 - this line is not working properly:

 //Inject a ResourceResolver
 ResourceResolver resourceResolver = resolverFactory.getAdministrativeResourceResolver(null);

Best practice in 6.1 is to use an AEM system user and use code like: 

Map<String, Object> param = new HashMap<String, Object>();
        param.put(ResourceResolverFactory.SUBSERVICE, "jqom");
        ResourceResolver resolver = null;
          
        try {
                     
            //Invoke the getServiceResourceResolver method to create a Session instance
            resolver = resolverFactory.getServiceResourceResolver(param);

To learn how to create a system user and use it to create a ResourceResolver - see this AEM community article: 

https://helpx.adobe.com/experience-manager/using/jqom.html

Avatar

Correct answer by
Administrator

Adding to what Scott has mentioned, it is not good practice to use getAdministrativeResourceResolver method. It has been depricated from ResourceResolverFactory.

Please have a look at the link, it will answer all your questions :-

Link:- http://www.accunitysoft.com/resourceresolver-object-in-aem6-16-0-sling-services/

//Use getServiceResourceResolver()

Here step by step everythig is mentioned, how to use it. And how to use it in AEM 6 and AEM 6.1.

 

Depricated Info :- https://sling.apache.org/apidocs/sling7/org/apache/sling/api/resource/ResourceResolverFactory.html#g...

Forum Link:-http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage...

I hope this would help you.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

Avatar

Level 2

I tried creating system user and tried using getServiceResourceResolver instead of getAdministrativeResourceResolver, still it fails at same place with NullPointerException. Attached is the updated code.

Avatar

Level 2

Also attaching my version of client (simple java program) if you have trouble running swing client. It reads all the images in particular directory and try to upload them, as we have requirement to upload all the files in particular directory. 

Avatar

Employee Advisor

I tested the binary code available on the documentation page with AEM 6.1 instance and it worked fine for me. This is what I did- 

  • Installed the bundle jar(in DAMSlingServlet.zip) file using felix/console and activated the bundle. 
  • Clicked the bundle name in felix and checked the following

Validated the JPEG file in DAM and there were no exceptions. 

Avatar

Administrator

Hi 

As mentioned by Kunal, I too checked this package present in the documentation.

Its working fine with me too.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni