04-17-2018 11:27 AM
Hello !
I'm facing an issue with rules triggering in Alfresco (Community v5.2.0 (r135134-b14) schema 10 005).
In our installation, we are using the rules to:
We faced multiple issues and random behaviors that we fixed with a lot of checks in our JS code but one "unsolvable" case remains.
We have a rule that is used to prevent people to rename or delete folders with a name starting by "_" , this rule only applies to elements that have the custom property 'gofastreventDelete' set to true.
The problem is : When we are doing something on an element in a folder starting by "_", the rules will trigger on the document but also on the parent folder.
Exemple :
A delete request is called :
16:58:31,244 WebDAV request DELETE on path /alfresco/webdav/Sites/_Groups/_Var%20dump%20land/content%20(2).mp4
Rules triggers on the document :
16:58:31,345 ==== STARTING SCRIPT SCRIPT SYNCHRONIZE ====
16:58:31,346 Script called on content (2).mp4 / 10651e68-7a35-4727-a1d1-f6e889805656
............................SOME ACTIONS..............................
16:58:31,423 Request has been sent
16:58:31,423 Drupal answered OK
16:58:31,424 Closing XHR Object
16:58:31,424 ==== ENDING SCRIPT SCRIPT SYNCHRONIZE ====
But just after this, the rule to prevent to delete a folder starting with '_' is called, not on the document but on it's parent folder :
16:58:31,491 ==== STARTING SCRIPT SCRIPT PREVENT DELETE SPACE FOLDER ====
16:58:31,492 Script called on _Var dump land / eb8dc7e7-dd04-4a6a-8909-3c263e54e0e6
16:58:31,492 Edition of _Var dump land will lead to a crash.
16:58:31,492 Exception org.mozilla.javascript.JavaScriptException: ROLLBACK : Edition of a space folder is not authorized (workspace://SpacesStore/ca813b71-8f57-4057-8496-8a4d39ee3d63#17)
And the transaction is rollbacked.
Do you think it's possible to stop propagation in the first script ?
Thanks for your help !
Regards,
04-23-2018 02:27 PM
Are you using the "Items are deleted..." trigger and the "Execute script" action for your rule? I cannot recreate the case where a script gets called twice using that trigger and action for a simple, one-line script that just has a logger.debug statement in it.
Maybe your script logic is triggering the rule twice?
Have you considered using a lower-level behavior rather than a folder rule?
04-30-2018 04:13 AM
We have 4 rules applied on the 'Sites' folder. All sub folders iherit of the parent folder rules.
Update aspects : 'Items are created or enter this folder', execute a script to set some wanted custom aspects on items
Synchronize : 'Items are created or enter this folder, Items are updated, Items are deleted or leave this folder', to make a long story short, this script sends an HTTP request to another component.
Synchronize folder : No longer used
Prevent Edit Spaces : 'Items are deleted or leave this folder, Items are updated' if 'Type is : Folder', the script that we are talking about.
The problem is not about the double triggering of the rule(s) but more about the 'Prevent Edit Spaces' rule triggering on parent folder in the same transaction that the file deletion.
What do you mean by 'lower-level behavior' ?
Thanks a lot for your answer !
05-11-2018 05:25 PM
Sorry, I should have been more specific. By lower-level behavior I meant a Java behavior, see Implementing Custom Behaviors in Alfresco | ECMArchitect | Alfresco Developer Tutorials
Explore our Alfresco products with the links below. Use labels to filter content by product module.