cancel
Showing results for 
Search instead for 
Did you mean: 

Command servlet in 5.0.2

matthewpatin
Champ in-the-making
Champ in-the-making
Hi all,

I'm trying to use the command servlet to execute database scripts in Alfresco 5.0.2 like so:

http://localhost:8080/alfresco/command/script/execute/workspace/SpacesStore/dcf5c20c-5bef-411c-95f0-...

However, this functionality seems to have disappeared in Alfresco 5. The wiki doesn't seem to reflect this, nor can I find information in the forums about this change:

https://wiki.alfresco.com/wiki/URL_Addressability#CommandServlet

Does anyone know how I can access this functionality in Alfresco 5?

Thanks a million for your help.

Best regards,
Matthew
5 REPLIES 5

mrogers
Star Contributor
Star Contributor
You can't.   It was part of the old Alfresco Explorer interface which no longer exists.

matthewpatin
Champ in-the-making
Champ in-the-making
It makes sense that it's gone. The thing is, developing repository scripts without it is a nightmare. The only alternative I have for now is creating a fake folder that runs the script when I copy up a file.

Could you recommend an easier way to execute repository webscripts? Or is that as "agile" as possible?

Also, how open would development be to porting the servlet (or something similar) to Share? Was the functionality something that was consciously left out? Or was it just a side effect of abandoning the old client?

Thanks,
Matthew

henryh
Champ in-the-making
Champ in-the-making
Hi,

I found out the same thing at the hard way when our corporation updated from 4.0 to 5.0. Creating the scripts are PITA without the command to execute them from client.

-Henry

fmstasi
Champ in-the-making
Champ in-the-making

Since this is one of the first hits when searching for a solution to this problem, I'll add another answer.

I found the approach of building a generic content stream webscript (described in this post on ServerFault) very convenient. In Data Dictionary/Web Script Extensions create a folder for your webscript, e.g. under it/myorganization/jsrunner, and in this folder create a descriptor, e.g. jsrunner.get.desc.xml, with the following content:

<webscript kind="org.alfresco.repository.content.stream">
<shortname>Run script</shortname>
<description>Webscript to execute a repository script</description>
<url>/jsrun</url>
<format default="">extension</format>
<family>myorganization</family>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

Then create jsrunner.get.js:

// in this example we write the log directly in Company Home, YMMV
var log_node = companyhome.childByNamePath('jsrunner.log') ;
companyhome.removeNode(log_node) ;
var log_node= companyhome.createNode('jsrunner.log', 'cm:content') ;
var log_text = '' ;

// your code goes here, append to log_text some useful messages

log_node.content = log_text ;
model.contentNode = log_node ;

You need to refresh the webscripts once (from /alfresco/s/index), then you can change the js code and execute it again with no need to refresh. I had no need to add parameters to the webscript, but that is also quite straightforward. I think this approach is more flexible than the old execute command servlet.