automating multiple digital asset upload | Community
Skip to main content
vishalp01051978
New Participant
January 11, 2016
Solved

automating multiple digital asset upload

  • January 11, 2016
  • 7 replies
  • 1433 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by kautuk_sahni

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#getAdministrativeResourceResolver-java.util.Map-

Forum Link:-http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.html/forum__am3i-i_am_tryingtouset.html

I hope this would help you.

Thanks and Regards

Kautuk Sahni

7 replies

kautuk_sahni
Employee
January 15, 2016

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
Kunal_Gaba_
New Participant
January 15, 2016

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. 

vishalp01051978
New Participant
January 14, 2016

Were you able to try it?

vishalp01051978
New Participant
January 12, 2016

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. 

vishalp01051978
New Participant
January 12, 2016

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.

kautuk_sahni
kautuk_sahniAccepted solution
Employee
January 12, 2016

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#getAdministrativeResourceResolver-java.util.Map-

Forum Link:-http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.html/forum__am3i-i_am_tryingtouset.html

I hope this would help you.

Thanks and Regards

Kautuk Sahni

Kautuk Sahni
smacdonald2008
New Participant
January 11, 2016

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