cancel
Showing results for 
Search instead for 
Did you mean: 

Doclib action evaluator for MyFiles section

nikes
Champ on-the-rise
Champ on-the-rise
Hello,

I have a requirement to hide "Manage Permissions" action just for the MyFiles section and keep for Repository and Site document library section.

I found this evaluator,
http://docs.alfresco.com/5.0/concepts/doclib-predefined-evaluators-reference.html

evaluator.doclib.action.siteBased

If we negate this, means non site context pages. means repository, shared files, and my files

How can I use it to just evaluate to true/false only for MyFiles section?

Thanks in advance.

Thanks,
Nikesh
1 REPLY 1

nikes
Champ on-the-rise
Champ on-the-rise
I solved it by custom doclib action evaluator.


Here is the code I used. (Not added exception handling yet. 🙂 )


package org.alfresco.web.evaluator;

import org.alfresco.error.AlfrescoRuntimeException;
import org.json.simple.JSONObject;
import org.springframework.extensions.surf.support.ThreadLocalRequestContext;

/**
* Determines whether a site-based node is being accessed via the Site Document Library
*
* @author mikeh
*/
public class MyFilesBasedEvaluator extends BaseEvaluator
{
    @Override
    public boolean evaluate(JSONObject jsonObject)
    {
       String containsHome = ThreadLocalRequestContext.getRequestContext().getUri();
       
       if(containsHome.contains("user/home") || containsHome.contains("/page/context/mine")){
          
          return false;
       }
       else{
          return true;
       }       
    }
}



<!– Manage permissions (repository roles) –>
         <action id="document-manage-repo-permissions" type="pagelink" icon="document-manage-permissions" label="actions.document.manage-permissions">
            <param name="page">manage-permissions?nodeRef={node.nodeRef}</param>
            <permissions>
               <permission allow="true">ChangePermissions</permission>
            </permissions>

            <!– Custom evaluator to disable Manage Permissions action at My Files section
            <evaluator>evaluator.doclib.action.myFilesBased</evaluator>

            <evaluator negate="true">evaluator.doclib.action.siteBased</evaluator>
            <evaluator negate="true">evaluator.doclib.action.isWorkingCopy</evaluator>
         </action>




<bean id="evaluator.doclib.action.myFilesBased" class="org.alfresco.web.evaluator.MyFilesBasedEvaluator" />


Thanks for any further comments or suggestions to improvement in code.