AnsweredAssumed Answered

Delete node rendition using JS API

Question asked by rvarkonyi on Dec 8, 2014
Latest reply on Dec 11, 2014 by rvarkonyi
Hi all,

I'm experiencing a strange behavior using the combination of Rules and JS API and it would be really great if someone could point me in the right direction.

We're uploading PDF documents into a given folder structure in Alfresco and using a Rule to create JPEG renditions from these PDF documents and copy them into a different folder - this part is working fine. The client specified a use case for deleting original assets, in which case we want to make sure to delete the renditions of a given asset too. Simply using Rules doesn't allow us to do that so we're trying to accomplish this using the JS API, with a script executed by a Rule.

I've been testing the following script in the Javascript console :

var renditions = renditionService.getRenditions(document);

for each (rendition in renditions) {
     try {
     catch (err) {

This seems to work fine when run on a selected asset.

However, using Rules it seems to break with the following message from the log:

DEBUG [repo.jscript.ScriptLogger] [http-bio-8080-exec-6] JavaException: java.lang.IllegalStateException: Operation not allowed against node pending deletion.  Check the node for aspect {}pendingDelete

On the front-end (Share) I can see this message: "Could not delete {filename}", and I can confirm that neither the original asset nor the rendition gets deleted. The error message in the log is not too helpful (not for me at least) so it would be great to get some advice from experienced developers.

Thanks in advance,