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

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

Avatar

Level 1

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

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

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.

View solution in original post

5 Replies

Avatar

Employee Advisor

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.

 

 

 

Avatar

Level 4

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.

Avatar

Correct answer by
Employee Advisor

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.

Avatar

Level 1

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