cancel
Showing results for 
Search instead for 
Did you mean: 

Restricting a menu item to a specific Space

vasuki
Champ in-the-making
Champ in-the-making
Hi, I have added a new menu item (using web-client-config-custom.xml) that will trigger a Javascript. Now, I would like to limit the Spaces that this menu item shows up…
I assume I need to use the "evaluator" and "condition" attributes (config tag) to do this, but I cannot find any documentation on how these are used. Should I be using the "string-compare" evaluator, and if so, how do I specify that I want this action restricted to a single space (and all documents and subspaces within it)?
31 REPLIES 31

rivarola
Champ on-the-rise
Champ on-the-rise
The Alfresco code throwing the Exception is :
         try
         {
            Class clazz = Class.forName(getEvaluatorClassName());
            objEvaluator = clazz.newInstance();
         }
         catch (Throwable err)
         {
            throw new AlfrescoRuntimeException("Unable to construct action evaluator: " + getEvaluatorClassName());
         }

It is not a parsing problem but the evaluator class cannot be instanciated.
Are you sure your class is in the application classpath ?

paullewon
Champ in-the-making
Champ in-the-making
Hi rivarola,

I may be confusing myself with the nuances of this particular customization. How can I verify that the class is on the application classpath?

Paul

rivarola
Champ on-the-rise
Champ on-the-rise
Hello,

In any JSP, for instance browse.jsp, add this somewhere :
<% new org.alfresco.web.action.evaluator.SciRCFolderIsReview(); %>
Then browse any folder. If it throws an exception, post it there. Otherwise the truth is somewhere else  :evil:

paullewon
Champ in-the-making
Champ in-the-making
It throws an exception:

javax.faces.FacesException: Unable to compile class for JSP:

An error occurred at line: 463 in the jsp file: /jsp/browse/browse.jsp
org.alfresco.web.action.evaluator.SciRCFolderIsReview cannot be resolved to a type
460: <h:outputText id="col13-2-txt" value='#{r["gc:status"]}' />
461: </a:column>
462:
463: <% new org.alfresco.web.action.evaluator.SciRCFolderIsReview(); %>
464:
465: <%– Path column for search mode in details view mode –%>
466: <a:column id="col14" style="text-align:left" rendered="#{NavigationBean.searchContext != null && BrowseBean.browseViewMode == 'details'}">


Stacktrace:
at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:425)
at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:211)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 463 in the jsp file: /jsp/browse/browse.jsp
org.alfresco.web.action.evaluator.SciRCFolderIsReview cannot be resolved to a type
460: <h:outputText id="col13-2-txt" value='#{r["gc:status"]}' />
461: </a:column>
462:
463: <% new org.alfresco.web.action.evaluator.SciRCFolderIsReview(); %>
464:
465: <%– Path column for search mode in details view mode –%>
466: <a:column id="col14" style="text-align:left" rendered="#{NavigationBean.searchContext != null && BrowseBean.browseViewMode == 'details'}">


Stacktrace:
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:691)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:419)
… 21 more

Paul

rivarola
Champ on-the-rise
Champ on-the-rise
Seems your type is not known by the system.
You stated that the JAR containing your custom evaluator is in /opt/alfresco/tomcat/webapps/alfresco/WEB-INF/lib.
Can you run a jar -tvf command on it, like
jar -tvf /opt/alfresco/tomcat/webapps/alfresco/WEB-INF/lib/you_jar.jar
(the jar utility is in the bin dir of your JDK) ?

paullewon
Champ in-the-making
Champ in-the-making
Thanks rivarola, that gave me the insight I needed to solve the problem.

If I can ask an additional question…

I have a structure of spaces in Alfresco as follows:

Company Home
   Scirola Reader Content
      Data Store
      Outbound
      Ready for Review
   Maricopa Content
      Data Store
      Outbound
      Ready for Review
      
I need to restrict some of my menu options by the space and parent space. My current code is:

package org.alfresco.web.action.evaluator;

import org.alfresco.web.action.ActionEvaluator;
import org.alfresco.web.bean.repository.Node;

public class SciRCFolderIsReview implements ActionEvaluator
{
    public boolean evaluate(Node node)
    {
        return (node.getPath().contains("Ready for Review"));
    }
}
But it's failing on the spaces in "Ready for Review". And it's failing when I try a more complete path, so as to restrict the menu option to just the Ready for Review folder within Maricopa Content.

Paul

vasuki
Champ in-the-making
Champ in-the-making
Hi Paul,

I think this problem has to do with having space characters in the names of your spaces (no pun intended). I avoid using space characters in Alfresco for just this reason. To see what I mean, just add the following line to your evaluator class, and watch the console output…

System.out.println(node.getPath());
If I'm right, I suspect you will see that the space characters get converted to underscores (or something else possibly) in the path returned…

Vasuki.

tfpadilla
Champ in-the-making
Champ in-the-making
I am trying to follow your instructions, to restrict the menu item to a space.
But my problem is that I am completely new on this ( also in Java) and I have problem to make the java class.

I have a file thesis.java
I try to compile it by: javac  thesis.java and I get a lot of errors like

thesis.java:3: cannot find symbol
symbol  : class ActionEvaluator
location: package org.alfresco.web.action
import org.alfresco.web.action.ActionEvaluator;
                               ^
thesis.java:4: package org.alfresco.web.bean.repository d
import org.alfresco.web.bean.repository.Node;
                                        ^
thesis.java:6: cannot find symbol
symbol: class ActionEvaluator
public class thesis implements ActionEvaluator
                               ^
thesis.java:8: cannot find symbol
symbol  : class Node
location: class org.alfresco.web.action.evaluator.thesis
    public boolean evaluate(Node node)
                            ^
4 errors

I know this is very basic, but PLEASE, could you help me.

Thanks in advance

vasuki
Champ in-the-making
Champ in-the-making
Hello tfpadilla,

Please make sure you have the Alfresco libraries on your classpath before compiling any custom classes.
You can use the "-cp" option to javac for this…

Good luck!
Vasuki.

tfpadilla
Champ in-the-making
Champ in-the-making
Hi vasuki,

Thanks a lot for your help. Smiley Very Happy
You were right and the problem was the classpath.
After that I could compile and after that integrate the new class in the package.
Now the new menu item works as expected.
Thanks again. When you are beginning with something and you are a complete "roockie", help and attention from experts is really apreciated.

Tfpadilla