cancel
Showing results for 
Search instead for 
Did you mean: 

prevent from removing aspect

vincent-kali
Star Contributor
Star Contributor
Hi,
We've created a new custom aspect (let say MyAspect), that can be added to content or folder types.
This aspect is then applied to all childs recursively using custom behavious. This works fine.

I'd like to prevent users (even admin) to remove this aspect if the parent has MyAspect set.
I don't know how to handle this, even with custom behaviour….

Any idea / suggestion ?

Thanks,
Vincent
6 REPLIES 6

leonardo_celati
Champ in-the-making
Champ in-the-making
If you already have a custom model, you can easily register your class which implements

NodeServicePolicies.BeforeRemoveAspectPolicy#BeforeRemoveAspect(NodeRef,QName)

There you can inspect node, parent node etc, and act consequently.

Hi Leonardo,
Thanks for reply.
I use exactly what you explained (BeforeRemoveAspect policy), but I don't know what to do in my code to block the user action (removing aspect)…
Should I throw a specific type of exception ?

Vincent


vincent-kali
Star Contributor
Star Contributor
really nobody has an idea ?

Try to have a look at this Alfresco class. This is actually what I am doing in my custom behavior.
I am still trying to find much more elegant way, for example with Custom Policy, but I am unable to fit this into a class behaviour.

<a href="https://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/repository/source/ja...">AliasableAspect.java</a>

See if it helps

Hi,
Thanks for your reply.
I'll try to throw an AlfrescoRuntimeException (as seen in your example) and give feedback here.

Vincent

vincent-kali
Star Contributor
Star Contributor
Throwing an AlfrescoRuntimeException makes the job.
Thanks !
Vincent