Questions - Move api for bulk moves, Jcrutils and resource resolver api | Community
Skip to main content
Level 9
July 22, 2022
Solved

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

  • July 22, 2022
  • 1 reply
  • 1093 views

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

 

 

 

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 Sachin_Arora_

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-java-api-best-practices.html?lang=en
https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/index.html

 

 

1 reply

Sachin_Arora_
Community Advisor
Sachin_Arora_Community AdvisorAccepted solution
Community Advisor
July 22, 2022

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-java-api-best-practices.html?lang=en
https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/index.html

 

 

Level 9
July 22, 2022

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. 

Sachin_Arora_
Community Advisor
Community Advisor
July 24, 2022

Please refer this document for different createPath methods.

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/commons/jcr/JcrUtil.html#createPath-javax.jcr.Node-java.lang.String-boolean-java.lang.String-java.lang.String-javax.jcr.Session-boolean-

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/developing/development-guidelines.html?lang=en#background-tasks-and-long-running-jobs