Getting " com.adobe.granite.asset.api.AssetException: javax.jcr.ItemExistsException " when trying to move the asset using assetmanager with the help of workflow.. | Community
Skip to main content
May 21, 2022
Solved

Getting " com.adobe.granite.asset.api.AssetException: javax.jcr.ItemExistsException " when trying to move the asset using assetmanager with the help of workflow..

  • May 21, 2022
  • 4 replies
  • 2133 views

Hi, I tried to automate the process and move the asset from one folder to another using workflow in which i moved the asset using assetmanager. However if the same asset is present in the destination folder it is supposed to replace the exiting one but it is not, and i m getting itemExistException when check in to the logs. Please provide any pointers how to replace the existing asset if there is any OOTB functionality need to be enabled for this.

Thanks

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 joerghoh

Unfortunately the assetManager API does not offer a "move" operation, thus you have to build it yourself using the Sling Resource API (or JCR). In that you have to implement the logic to avoid collisions yourself.

4 replies

arunpatidar
Community Advisor
Community Advisor
May 21, 2022
DEBAL_DAS
May 21, 2022

Let me share my observations during authoring activity associated with create and move operation.

Let's assume that under this /content/dam/we-retail/en/people path one asset named: we-retail.pdf is already available and now you want to upload same file (similar name) from your system.

Here you are doing create operation and this time AEM will give you options like: replace, create versions etc.

 

During move operation (authoring activity) , we will be able to move same file but after moved file will be renamed as we-retail1.pdf as we already have file named: we-retail.pdf in the same place.

 

Please note that in AEM , node name represents 'ID' and ID should be unique. 

You could validate at your end also.

 

Now you need to modify the business logic  during move operation considering all these points.

 

 

 

Level 3
May 21, 2022

One hack would be to check for that asset path before doing the move operation, if it exists, you can delete it and do session save, then move the new one on that path.

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
May 22, 2022

Unfortunately the assetManager API does not offer a "move" operation, thus you have to build it yourself using the Sling Resource API (or JCR). In that you have to implement the logic to avoid collisions yourself.

ssawaikarAuthor
May 26, 2022

Hi @9372713  could you please elaborate what you are trying to say here.