cancel
Showing results for 
Search instead for 
Did you mean: 

Using a folder rule to execute a script from the classpath?

dnallsopp
Champ in-the-making
Champ in-the-making
I would like to use a folder rule to trigger a script, using the normal "Manage Rules" wizard. The pull down menu for "Execute Script" seem to be populated from the scripts in Data Dictionary/Scripts in the repository - this all works fine.

However, is there a way to include scripts from the classpath instead, in this menu? If so, where should they go?

The reason I want to do this is so that I can automate the installation of the server, including putting the scripts into the relevant classpath folder. I don't really want to have to manually upload scripts to the repo every time we set up a test VM, which we may do very frequently during development. We are aiming for a fully automated deployment and configuration of a server and Share Site.

Presumably another alternative would be to automate the upload of the scripts into the repo when installing it - what would be the easiest way to do this? FTP and CIFS will be disabled in our setup, so perhaps I'd need to use a webscript to upload them? Or is there some way to automatically run one-off initialisation scripts when the repo is first run?

Thanks for any pointers…

Update: another thought - does anyone use the Export and Import functionality for this kind of configuration? Explicit scripting would be better, but importing folders/permissions/rules might work…
3 REPLIES 3

scouil
Star Contributor
Star Contributor
Hello,

You can of course add the scripts in your file system in
<tomcat home>\shared\classes\alfresco\extension\scripts\yourscript.js

However the scripts in the file system have a major drawback: every time you update a script, you have to fully restart your server.

dnallsopp
Champ in-the-making
Champ in-the-making
Hi,

I tried adding a script to:

  /opt/alfresco-4.0.e/tomcat/shared/classes/alfresco/extension/scripts/

and restarting the server, but no luck -  the script doesn't seem to be picked up by the menu in Edit Rule->Perform Action->Execute Script.

Only the "Start Pooled Review and Approve Workflow" script appears in this menu.

I also tried the script in /opt/alfresco-4.0.e/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/extension/scripts/ and restarting, but again no luck - not sure whether this should have the same effect as putting it in shared.

The script is just a one-liner as shown below, though presumably it makes no difference since it won't be read until execution time:

logger.log('+++ Logging test script +++');

scouil
Star Contributor
Star Contributor
Hello.

Then the extension/scripts folder isn't automatically picked up, my bad.
You probably need to register your action through spring then.

webapps/alfresco/WEB-INF/classes/alfresco/* is mostly the same as shared/classes/alfresco/extension . However, webapps/alfresco/* is from Alfresco jar and will be lost when you upgrade alfresco that's why the good practice is to put your extensions in shared/*

Regards,