cancel
Showing results for 
Search instead for 
Did you mean: 

Creating custom evaluator in alfresco 4

g_rathod
Star Contributor
Star Contributor
Hi,
I need to create custom evaluator in alfresco enterprise 4 (documentLibrary folder action).
If there is specific type of folder then only show this action else not.

I followed below steps but its not much useful.

1) share-documentlibrary-config.xml

<action id="folder-assign-workflow" type="javascript" label="actions.folder.assign-workflow">
               <param name="function">onActionAssignWorkflow</param>
               <evaluator>evaluator.doclib.action.customDraftBased</evaluator>
          </action>

 
 <actionGroup id="folder-browse">
               <action index="261" id="folder-assign-workflow" icon="folder-edit-properties" label="Start Custom Workflow"/>
         </actionGroup>


2)  slingshot-documentlibrary-context.xml

 <bean id="evaluator.doclib.action.customDraftBased" class="com.clms.web.evaluator.CustomDraftBasedEvaluator" />

3) CustomDraftBasedEvaluator.java

public class ClmsDraftBasedEvaluator extends BaseEvaluator {

   @Override
   public boolean evaluate(JSONObject jsonObject) {
      System.out.println("*** JSONObject  ::" + jsonObject);
      return true;
   }

}

It will not showing me my custom action. I tried keeping action and actionGroup inside share-config-custom.xml  action appears but at that time evaluator did not work.

Any help on this appreciated.
11 REPLIES 11

acarpine
Champ in-the-making
Champ in-the-making
Hi g_rathod,
I have a similar problem trying to use a custom Evaluator for a custom action.

1) Have you tried to
public class ClmsDraftBasedEvaluator implements ActionEvaluator
instead of
public class ClmsDraftBasedEvaluator extends BaseEvaluator
?

2) Have you any interesting log message in alfresco.log?

acarpine
Champ in-the-making
Champ in-the-making
[…]

2)  slingshot-documentlibrary-context.xml

 <bean id="evaluator.doclib.action.customDraftBased" class="com.clms.web.evaluator.CustomDraftBasedEvaluator" />

3) CustomDraftBasedEvaluator.java

public class ClmsDraftBasedEvaluator extends BaseEvaluator {

   @Override
   public boolean evaluate(JSONObject jsonObject) {
      System.out.println("*** JSONObject  ::" + jsonObject);
      return true;
   }

}

btw I believe that the attribute class of your bean should match the class name.
You used ClmsDraftBasedEvaluator as evaluator class name and CustomDraftBasedEvaluator as class name reference in your bean. Could you check if you have an exception caused by Spring during startup (alfresco.log)?

g_rathod
Star Contributor
Star Contributor
Hi acarpine,

Thanks for your reply,

Sorry it was typo actually it is "CustomDraftBasedEvaluator"  instead "ClmsDraftBasedEvaluator".
and using evaluator As I have observed out of box things they have extending BaseEvaluator everywhere instead "ActionEvaluator".

I will try with your given approach and check again.
Did you able to get your custom evaluator? actually I need to check with specific type of space only show my custom action, out of box they had given for aspect.

any clue will be fine.

Thanks,

acarpine
Champ in-the-making
Champ in-the-making
I was able to define my custom evaluator in Alfresco Explorer but I'm not able to use it in Alfresco Share.
Seem that the Spring bean is not correctly loaded at startup time (so the Evaluator is not loaded)…but I can't figure out what I'm missing…

I believe you have a slightly different issue because you don't see any exception in the alfresco.log, anyway
in case of any progress I will let you know

g_rathod
Star Contributor
Star Contributor
Hi acarpine,

Even I have same issue, I could not find my evaluator "evaluator.doclib.action.customDraftBased"
my tomcat log says :
2012-03-12 11:54:16,906  WARN  [web.scripts.ActionEvaluatorHelper] [http-8080-26] Evaluator 'evaluator.doclib.action.customDraftBased' not found.

What I need to achieve is like below :
- Where ever in document library, I have clmSmiley Very Happyraft type folder I need to show one extra custom action of workflow.
Currently I can see that action to every folders instead specific type of folder ..
this way my Evaluator not working.

Anyone have achieved like this in alfresco share 4?

g_rathod
Star Contributor
Star Contributor
Hello Friends,

Finally I resolved this issue:

you can look at : http://alfrescocms.blogspot.in/2012/03/custom-document-library-action.html

power
Champ in-the-making
Champ in-the-making
Hi g_rathod,

Its really awesome job u did.
Thanks a lot.

acarpine
Champ in-the-making
Champ in-the-making
Hello Friends,
Finally I resolved this issue:
you can look at : http://alfrescocms.blogspot.in/2012/03/custom-document-library-action.html

Ops…I believe that my goal is different from yours because I'm trying to use a "new" evaluator
(a java class that implements an Alfresco evaluator). You solved the problem just using a specific
configuration for an Alfresco evaluator.

Anyway good job g_rathod 🙂

g_rathod
Star Contributor
Star Contributor
Hi  acarpine,

You are right, for simple type check this solution works, but when we need to check some more advance conditions we need our evaluator extending BaseEvaluator.
I already tried creating new evaluator by extending BaseEvaluator, but somehow that class is not loading at all.
Even though my jar file contains that class, bean is not identifying that class and throws an exception for ClassNotFound.