Return custom permission list for node

99 views Asked by At

I have a requirement where I want to hide the delete action in the share document library under certain circumstances. Those circumstances makes it impossible for me to use the property decorator extension mechanism in an effective way. (A source associated node should have a certain status).

Browsing the docs of how to extend the document library of Alfresco Share there is something described as "Permission List" (http://docs.alfresco.com/4.2/concepts/doclib-repository-tier.html) (heading 3)

I cannot figure how to use this extension mechanism in a proper way. I want to be able to lookup some things with the nodeService in the repository tier, and in some cases remove the Delete permission from the returned permission list.

[update] My first thought was of course to use a custom evaluator as proposed by @mitpatoliya in his answer, that based on the json returned from the server evaluates if the delete option should be present. However my requirement was to hide the option if a certain source associated node had a specific property value. To do this I would have to do a remote REST call from the evaluator code. This was something I wanted to avoid if I could.

3

There are 3 answers

1
mitpatoliya On

Best way to hide actions are to use action evaluators.

So you could extend any one of the action evaluators as per your requirement and then override the action config in share-config-custom.xml to hide that action when particular action is invoked.

Here is the list of out of box action evaluators.

http://docs.alfresco.com/4.1/concepts/doclib-predefined-evaluators-reference.html

You could also create your own evaluator if none of above meet your requirement.

https://forums.alfresco.com/forum/developer-discussions/alfresco-share-development/custom-action-evaluator-12132012-1900

4
billerby On

Well I don't know if this is the intended way to do this, but I subclassed the JSONConversionComponent.userPermissionsToJSON method, and made it work.

1
Marco Altieri On

@billerby, you are right, evaluators usually need to execute a call to the repository but this is how they are supposed to work. If you get any evaluator, you can find how this call is implemented. It is a very standard implementation that it is better to start using. At least, this is what I would suggest.