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

Questions - Move api for bulk moves, Jcrutils and resource resolver api

Avatar

Level 10

All,

 

I am trying to create folders and move assets- performing bulk move

Anyone knows

 

1. if jcrutil.createPath can help me best create nodes that are sling:folders WITH jcr content? I tried using.createPath which created missing nodes but no jcr:content. Want to confirm and know i  am not missing something that could help me create a folder with jcr content using createPath command.trying to save on commits

 

2. Also i ended up using resourceresolver.create , creating folder along with it's properties and jcr content, as what acs folder creator does, 

Question i have is , does it automatically save without explicit resourceResolver.commit? I believe so but want to hear from others

3. Using assetmanager.moveAsset on a folder with assets and deeply nested , and then performing a save would be ok? Will be performing tests to confirm , but want to hear if anyone has experience on this

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

As per best practice always choose AEM API first so I would suggest to use AssetManager in you case.

You can use Sling Jobs as well to process each asset. I have used in one of the project and things went smooth. We did migration of assets from one folder to another folder. Please keep check of following things : references update in Assets or Pages, collections update.

Document for Java API Best Practices :

 

https://experienceleague.adobe.com/docs/experience-manager-learn/foundation/development/understand-j...
https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/index.html

 

 

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

As per best practice always choose AEM API first so I would suggest to use AssetManager in you case.

You can use Sling Jobs as well to process each asset. I have used in one of the project and things went smooth. We did migration of assets from one folder to another folder. Please keep check of following things : references update in Assets or Pages, collections update.

Document for Java API Best Practices :

 

https://experienceleague.adobe.com/docs/experience-manager-learn/foundation/development/understand-j...
https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/index.html

 

 

Avatar

Level 10

Thanks 

@Sachin_Arora_  .My question would be does .create method auto save?

I would have expected jcrutils.createPath to create nodes and jcrcontent if it does not exist , but does not seem to be the case

We don't care of references at the moment so i believe assetmanager.move should do , can you please elaborate on sling jobs approach for this. 

Avatar

Community Advisor

Please refer this document for different createPath methods.

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/commons/jc...

It wont create the whole skeleton of an Asset or Page, it will only create the specific Node that you will be passing as a parameter to Method. Few methods has parameter autoSave as well. Otherwise you can call session.save() in the end.
To create whole Asset with all required child Nodes, use AssetManager i.e. AEM API.

 

About Sling Jobs, it guarantees to be executed at least once.. We can control the number of re-execution of Job as well using configuration. Also it is recommended for AEMaaCS
Document : https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/implementing/develo...

 

Avatar

Level 10

My observation on the api is that it creates the entire non existent folder path. The jcr content nodes , that should exist associated to the folder does not get created .  jcrutils is not recommended per the last ref doc sent over,   @Sachin_Arora_  so skipping for these reasons 

Using resourceresolver.create is recommended per the doc and acs folder creator so using it . But looks like it needs saves after every create , which means one for folder and one for jcr content. But this is not super clear as acs code has no commits and the doc you shared has .. will try and test it out for confirmation and update 

 

sling jobs -I presume it also means schedulers and even handling 

if yes, this is what I am using but wanted to ensure I don’t burden the system with apis that should be carefully treaded with 

 

our system is a pure asset oriented vs content , we have like millions of assets