Prevent custom Aspect from being added to a node

13 views
Skip to first unread message

Leonardo Celati

unread,
Jan 28, 2015, 11:41:28 AM1/28/15
to alfresco-techn...@googlegroups.com
As in the subject, after having developed a custom model with associated behavior, I am looking for an "official" way to achieve this:

1) Apply aspect
2) Check if requisites are met (i.e. only cm:content, specific mime type...etc)
3) Prevent aspect from being added if necessary
4) Inform the user with a custom localized message that something went wrong

I followed many tutorial about custom behavior and policy, but I couldn't find a suitable example covering the subject.
I mean, most of them cover the policy onAddAspect and onRemoveAspect, but there's nothing related to the points above.

For the moment I am just throwing an error in beforeAddAspect policy, but seems not so much elegant.

If this matter, I am using Community 4.2.f.

Piergiorgio Lucidi

unread,
Feb 6, 2015, 9:10:24 AM2/6/15
to alfresco-techn...@googlegroups.com
Hi Leonardo,

I think that you should write your own script (JavaScript API), WebScript or a Custom Action dedicated to check this requirements before applying the aspect.

You can also then create a rule using the script or the action. Or you can create your REST service that executes this check for you injecting your script inside a Web Script.

Another way that you can follow could be creating a ScheduledAction for executing a query in the repository, executing the script and then decide if apply the aspect or not.

Finally you can implement your own Interceptor using Spring creating a new external Proxy related to the NodeService to add your new check.

Hope this helps.
Reply all
Reply to author
Forward
0 new messages