cancel
Showing results for 
Search instead for 
Did you mean: 

How to add a aspect to a folder to monitor content creation

silverhoof
Champ in-the-making
Champ in-the-making
I want to create an aspect that can be applied to a given folder.
This aspect's purpose is to monitor the content creation inside the applied folder. Which means I tried to define some behavior in the aspect to fire my custom logic when content is created inside the folder.
But my test code found that the we can't get event when files are created in a aspect allied folder. When I create a file under the folder, only the "beforeUpdateNode" event is triggered, but other event doesn't get the call back. I assumed that the "onCreateChildAssociation" will be triggered…

We want to find a way to monitor the created file in a folder through add behavior through aspect, please help me if you know how to do this, thanks a lot.
1 REPLY 1

mikemars
Champ in-the-making
Champ in-the-making
You should be fine to use onCreateChildAssociation()

When you register the behaviour with the policyComponent remember that you need to bind to the association and not the class i.e it should read:


this.policyComponent.bindAssociationBehaviour(
   QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateChildAssociation"),
   YourModel.YOUR_ASPECT,
   ContentModel.ASSOC_CONTAINS,
   new JavaBehaviour(this, "onCreateChildAssociation"));

NOT


this.policyComponent.bindClassBehaviour(
       QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateChildAssociation"),
       YourModel.YOUR_ASPECT,
       new JavaBehaviour(this, "onCreateChildAssociation"));

Also, something to think about when using onCreateChildAssociation is that if a file/folder is renamed, then this event it triggered. But these events can be filtered out if need be.