cancel
Showing results for 
Search instead for 
Did you mean: 

Problems launching script

rcortesr
Star Contributor
Star Contributor
Hi,

I would like to test the javascript backup.js.
I have created a button for lauch this script.
My web-client-config-custom.xml is the following:
<config> 
<actions>
<!– Launch Test Javascript Dialog –>
<action id="test_js">
<label>Test Javascript</label>
<image>/images/icons/add.gif</image>
<script>/Company Home/Data Dictionary/backup.js</script>
</action>

<!– Add action to more actions menu for each space –>
<action-group id="document_browse">
<action idref="test_js" />
</action-group>
</actions>
</config>

When I execute the script appears to me the following error:
org.alfresco.error.AlfrescoRuntimeException: Error during command servlet processing: Unable to resolve item Path: /Company Home/Data Dictionary/backup.js 
at org.alfresco.web.app.servlet.CommandServlet.service(CommandServlet.java:176)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.IllegalArgumentException: Unable to resolve item Path: /Company Home/Data Dictionary/backup.js
at org.alfresco.web.app.servlet.BaseServlet.resolveNamePath(BaseServlet.java:315)
at org.alfresco.web.app.servlet.command.ScriptCommandProcessor.validateArguments(ScriptCommandProcessor.java:72)
at org.alfresco.web.app.servlet.CommandServlet.service(CommandServlet.java:128)
… 15 more

What is the problem??
I think that the path is correct.

Another question: Is it possible to create an action only for a single user?

Thanks.
15 REPLIES 15

doblek
Champ in-the-making
Champ in-the-making
Hi Kevin,

First of all, thanks for your quick response 😃

I've made the following changes in my configuration based on the link you pointed me:

web-client-config-custom.xml

<!– Adding a custom menu item for adding "Pending approval" aspect after being rejected –>
   <config>
      <actions>

         <action id="return_to_PendingApproval">
            <label>Return to "Pending Approval" state</label>
            <script>/Company Home/Data Dictionary/Scripts/applyPendingApprovalAspect.js</script>
            <params>
               <param name="id">#{actionContext.id}</param>
            </params>
         </action>
      <!– Add action to Actions Menu for Document Details screen–>
         <action-group id="doc_details_actions">
            <action idref="return_to_PendingApproval" />
         </action-group>
      <!– Add action to Actions Menu for a document in the Browse screen–>
         <action-group id="document_browse_menu">
            <action idref="return_to_PendingApproval" />
         </action-group>
      </actions>
   </config>

/Company Home/Data Dictionary/Scripts/applyPendingApprovalAspect.js

var doc_node = search.findNode("workspace://SpacesStore/"+args["id"]);
if (doc_node.isDocument){
   
   doc_node.removeAspect("dsm:docStatus_Rejected");
   doc_node.addAspect("dsm:docStatus_PendingApproval");
}

But it's still not working…  :cry: I can't see anything in Tomcat's console and Alfresco's log just say this:
19:24:15,890 ERROR [org.apache.catalina.session.ManagerBase] IOException al cargar sesiones persistidas: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.alfresco.web.bean.repository.QNameNodeMap
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.alfresco.web.bean.repository.QNameNodeMap
   at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1303)
   at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
   at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
   at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
   at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
   at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
   at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1386)

Apparently, it's like the script does nothing. Is there any way to debug the script?? Insert any trace saying "I've reached this or that point in the script"?

I've tested the following code as well, but it has no effect either.

/Company Home/Data Dictionary/Scripts/applyPendingApprovalAspect.js

var doc_node = search.findNode("workspace://SpacesStore/"+args["id"]);
doc_node.addAspect("cm:Templatable");


Any help would be very much appreciated. 😃

Thanks again,
Enrique

ivanmiha
Champ in-the-making
Champ in-the-making
Hi,

when I try the same thing as rcortesr I get a following error:

org.alfresco.error.AlfrescoRuntimeException: Error during command servlet processing: Failed to execute script 'workspace://SpacesStore/c7e271cc-77e3-11dc-a556-858e0f82a842': Failed to execute script 'workspace://SpacesStore/c7e271cc-77e3-11dc-a556-858e0f82a842': ReferenceError: "space" is not defined. (AlfrescoScript#2)
caused by:
org.alfresco.service.cmr.repository.ScriptException: Failed to execute script 'workspace://SpacesStore/c7e271cc-77e3-11dc-a556-858e0f82a842': Failed to execute script 'workspace://SpacesStore/c7e271cc-77e3-11dc-a556-858e0f82a842': ReferenceError: "space" is not defined. (AlfrescoScript#2)
caused by:
org.alfresco.service.cmr.repository.ScriptException: Failed to execute script 'workspace://SpacesStore/c7e271cc-77e3-11dc-a556-858e0f82a842': ReferenceError: "space" is not defined. (AlfrescoScript#2)
caused by:
org.alfresco.error.AlfrescoRuntimeException: ReferenceError: "space" is not defined. (AlfrescoScript#2)
caused by:
org.mozilla.javascript.EcmaError: ReferenceError: "space" is not defined. (AlfrescoScript#2)



What is wrong?

Thanks,
Ivan

kevinr
Star Contributor
Star Contributor
Enrique,

Yes you can use the Logger to output log values to your console screen (you also need to enable the following class in your log4j.properties file in the alfresco\WEB-INF\classes folder:
log4j.logger.org.alfresco.repo.jscript=debug

See http://wiki.alfresco.com/wiki/JavaScript_API#Logging_API

It might be worth output the args["id"] value to check that it is what you think.

Thanks,

Kevin

rafaelscg
Champ on-the-rise
Champ on-the-rise
doblek,

Try to use this to return document object:

var nodeRef = args["noderef"];
var node = search.findNode(nodeRef);

And add this parameter in your action file:

<param name="noderef">#{actionContext.nodeRef}</param>

I think this is what you want. Tell if this is what you want to do

nhutminh87
Champ in-the-making
Champ in-the-making
Another question: Is it possible to create an action only for a single user?

Yes, you can use an evaluator (see the <evaluator> tags for an action) and compare the current username with the user target for the action, which is available using the code:

org.alfresco.web.app.Application.getCurrentUser()

Thanks,

Kevin

How can it use only for "admin"? some code? i'm new, pl help me.  :cry:
Thank all.

kevinr
Star Contributor
Star Contributor
Yes you can test to see if the user is an admin user via the AuthenticationService bean:

authenticationService.isAdminAuthority( usernamehere );

So that can be easily added to an evaluator.

Kev