cancel
Showing results for 
Search instead for 
Did you mean: 

CIFS desktopactions - ScriptAction.execute error

darcy
Champ in-the-making
Champ in-the-making
Hello all,

I am using Alfresco 1.4.0 community.

I am having trouble running a desktop action in order to change the content type to a custom type when importing via CIFS. I am not sure I understand correctly how to do it. Here is what I have:

in file-servers-custom.xml:

               
<action>                             
      <class>org.alfresco.filesys.smb.server.repo.desk.JavaScriptDesktopAction</class>
      <name>JavaScriptAction</name>
      <filename>__AddIntranetContent.exe</filename>
      <script>alfresco/desktop/tcsAction.js</script>
      <attributes>anyFilesFolders</attributes>
      <preprocess>copyToTarget</preprocess> 
</action>

in alfresco/desktop/tcsAction.js:


function runAction()
{
   var script = actions.create("specialise-type");
   script.parameters["type-name"] = "tcs:content";
   script.execute(deskParams.getTarget(0).getNode());
}

runAction();
var response = "0,Javascript completed successfully";
response;   

When I invoke the action, I get a windows dialog error:


Error running action

Failed to execute supplied script: Can't find method org.alfresco.repo.jscript.Actions$ScriptAction.execute(org.alfresco.service.cmr.repository.NodeRef).

"specialise-type" is in the actions array available to the javascript action. If I understand correctly how that works, the script is mapped to the org.alfresco.repo.action.executer.SpecialiseTypeActionExecuter class. Looking at the API, the execute method takes an additional parameter: org.alfresco.service.cmr.action.Action. The JavaScript API doesn't supply this parameter and I have no idea what I would supply for it.

In addition, if I use the "mail" example from the wiki, I get the same error. In this case I am supplying the same deskParams.getTarget(0).getNode() object to execute. From the API, that looks like the right param.

Changing the type to a custom type is the goal, there may be another way to do it that I am unaware of.

Any help would be much appreciated.

Thanks!
4 REPLIES 4

darcy
Champ in-the-making
Champ in-the-making
no one has any ideas?

kevinr
Star Contributor
Star Contributor
The problem here is the deskParams.getTarget(0).getNode() parameter. You are correct that the Repository action API for that particular action expects a NodeRef - but the JavaScript API world deals in wrapper objects - it does not work with NodeRef instances directly. So the JavaScript 'actions' object is expecting a JavaScript Node object as the action parameter - not a NodeRef.

The workaround is to use the JavaScript 'search' object to find the node represented by the NodeRef and wrap it into the expected Node object:

function runAction()
{
   var script = actions.create("specialise-type");
   script.parameters["type-name"] = "tcs:content";
   var node = search.findNode(deskParams.getTarget(0).getNode());
   script.execute(node);
}

runAction();
var response = "0,Javascript completed successfully";
response;
I think that should work Smiley Happy

As far as fixing the issue - we need to either fix the jscript desktop actions objects to correctly wrap NodeRef as Node objects - or change the JavaScript 'actions' object to handle NodeRef parameters.

Thanks,

Kevin

kevinr
Star Contributor
Star Contributor
I have raised a JIRA task for this:
http://issues.alfresco.com/browse/AR-1121

darcy
Champ in-the-making
Champ in-the-making
Thanks Kevin,

Unfortunately, the 'search' object is not available to the jscript desktop action, looks like it is only available to the jscript actions in the Web Client maybe? I see it in the Javascript API on the wiki, but it is not Javascript Desktop Action. I get an error when trying to access it also.

In any event, for my particular situation I found a better way to handle the converting of the content, that was to just use a rule with the specialise-type option: http://forums.alfresco.com/viewtopic.php?t=2527&highlight=specialise
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.