cancel
Showing results for 
Search instead for 
Did you mean: 

Is runCommand or an equivalent available from Javascript

sgray
Champ in-the-making
Champ in-the-making
I'm brand new to Alfresco and was evaluating whether we could perform a fairly complex task that involves handling input TIFF files.  I wanted to run them through a Javascript rule that would call a program which extracts barcode information.  This would be attached to the document as another property and would be available for use by downstream tasks.

Checking the Mozilla's Rhino Javascript website I found their support for the runCommand function which allows a shelled application to be run.  This fails under the current version of Alfresco (2.0 Community).

I see that various problems like this have produced the recommendation to customize the repository 'actions'.  Is this my only alternative or has anyone a better solution?

Thanks for the response!  I'm pretty impressed with Alfresco so far and have as yet to fully explore all it's possibilities.

Steve
1 REPLY 1

kevinr
Star Contributor
Star Contributor
For security reasons (i.e. that any user with READ access can execute a javascript etc.) we have turned off certain native Rhino features i.e. the ability to import java classes directly and use them. Obviously it doesn't take much imagination to see how a user with very low security in Alfresco could write and execute a very dangerous javascript file…

So the way around this is to code up a java class that performs the code work that you need (such as executing external commands) and then configure that Java class in as an extension object to the JavaScript API - this is the supported pattern:
http://wiki.alfresco.com/wiki/JavaScript_API#Adding_custom_Script_APIs

Thanks,

Kevin