chainedMatchAll & chainedMatchOne syntax/example

cancel
Showing results for 
Search instead for 
Did you mean: 
zputnoky
Established Member

chainedMatchAll & chainedMatchOne syntax/example

Dear All,

Still trying to hide/activate document library actions based on user role settings.

The code below hides the move to action, but unfortuantely hides for all users:

<config evaluator="string-compare" condition="DocLibActions" parent="evaluator.doclib.action.chainedMatchAll "> 
     <actions>
          <action id="document-download" type="javascript" label="actions.document.move-to">
               <param name="function">onActionMoveTo</param>
               <evaluator>evaluator.doclib.action.isSiteConsumer</evaluator>
               <evaluator>evaluator.doclib.action.disableAction</evaluator>
     </action>
     </actions>
</config>

I am not sure about the usage of evaluator.doclib.action.chainedMatchAll here.

Is there an example somewhere about how to use the chainedMatchAll and chainedMatchOne evaluators?

Regards,

Zsolt Putnoky

5 Replies
afaust
Master

Re: chainedMatchAll & chainedMatchOne syntax/example

Setting the parent attribute does not make sense in this configuration file - this attribute is not supported at all and will be ignored. "parent" is an attribute that you use in Spring configuration files, not the Alfresco Share configuration files. As always, the source of Alfresco is the best example to look at for usages of chainedAll etc.

zputnoky
Established Member

Re: chainedMatchAll & chainedMatchOne syntax/example

Thanks for the link! got the impression that I cannot chain together an evaluator which is checking user group membership and another one which is disabling a certain action.

Run into a demand, where I need to be able to hide certain document action based on the role of the logged in user. Basically I need to create company specific action groups out of the standard actions and show them depending on the user role.

douglascrp
Advanced II

Re: chainedMatchAll & chainedMatchOne syntax/example

Hello.

You can write a custom evaluator and make it check the user's membership to decide if the action should be active or not.

This is a simple example you can adapt to what you need:

public class IsSecretariaUserEvaluator extends BaseEvaluator {
private static String GRUPO_SECRETARIAS = "GROUP_SECRETARIAS";
protected SlingshotEvaluatorUtil util = null;
public void setSlingshotEvaluatorUtil(SlingshotEvaluatorUtil slingshotExtensibilityUtil) {
this.util = slingshotExtensibilityUtil;
}
public boolean evaluate(JSONObject jsonObject) {
ArrayList<String> groups = new ArrayList<String>();
groups.add(GRUPO_SECRETARIAS);
final RequestContext rc = ThreadLocalRequestContext.getRequestContext();
return this.util.isMemberOfGroups(rc, groups, false);
}
}

And then you declare it as:

<bean id="evaluator.doclib.isSecretaria" class="custom.evaluators.IsSecretariaUserEvaluator">
<property name="slingshotEvaluatorUtil" ref="slingshot.evaluator.utility" />
</bean>
zputnoky
Established Member

Re: chainedMatchAll & chainedMatchOne syntax/example

Hi Douglas,

Thanks for the code! Have a question though. Why I need an evaluator when Alfresco has an OOTB evaluator to check role?

Regards,


Zsolt Putnoky

douglascrp
Advanced II

Re: chainedMatchAll & chainedMatchOne syntax/example

Because you mentioned

an evaluator which is checking user group membership

By group membership I thought about a more generic kind of organization, like defining roles inside the company, and not inside the Alfresco's Share site (consumer, contributor, colaborator and manager).