Page 1 of 1
Scripting (start.bsh)
PostPosted:Tue Aug 23, 2011 11:44 am
by olexandr
Hello,
I'm trying to create autostart script, which add automatically property groups.
But I don't understand how to use variables correctly, for example when I have start.bsh like:
Code: Select allimport javax.jcr.*;
import com.openkm.core.*;
import com.openkm.bean.*;
import com.openkm.module.base.*;
String token = JcrSessionManager.getInstance().getSystemToken();
Session session = JcrSessionManager.getInstance().get(token);
String parent = com.openkm.util.FileUtils.getParent(eventNode.getPath());
I've got an error - eventNode variable not found.
How to correctly initialize this (and also these
http://wiki.openkm.com/index.php/Script ... ables_used) variables?
Regards,
Re: Scripting (start.bsh)
PostPosted:Fri Aug 26, 2011 8:04 am
by jllort
first try with
Code: Select allString parent = com.openkm.util.FileUtils.getParent(eventNode.getPath());
System.out.println(parent);
Re: Scripting (start.bsh)
PostPosted:Mon Aug 29, 2011 8:08 am
by pavila
The start.bsh script is executed when OpenKM starts (when JBoss starts) so there is no associated node nor event. If you want to do so, go to Administration > Repository view and put the scripting code in the desired folder.
Re: Scripting (start.bsh)
PostPosted:Fri Sep 23, 2011 8:55 am
by olexandr
Thank you very much for making things clear!
I've enabled scripting for the folder and automatic example script is generated:
Code: Select allprint("UserId: "+session.getUserID());
print("EventType: "+eventType);
print("EventNode: "+eventNode.getPath());
print("ScriptNode: "+scriptNode.getPath());
As far as I understand this should print user node info, when I enter the folder, but nothing happens. Should it print somewhere on the screen or somewhere in the logs?
Sorry for my questions - for me
http://wiki.openkm.com/index.php/Scripting is a bit condensed.
Re: Scripting (start.bsh)
PostPosted:Fri Sep 23, 2011 6:20 pm
by jllort
You must take a look at server.log ( tail -f server.log on linux ) or open with some windows editor ( gedit, ultraedit or similar )
Re: Scripting (start.bsh)
PostPosted:Sun Sep 25, 2011 9:15 am
by pavila
Scripting can be set by folder or document. You need to go to Administration > Repository view and browse the repository at low level. Be careful because and error can damage the document repository! When you have located the right place, select Scripting: Set script and a new scripting property will be added to the node. This property can be edited to set your custom code.
Re: Scripting (start.bsh)
PostPosted:Wed Oct 12, 2011 9:00 am
by olexandr
Hello, thank you for the replies!
But still it doesn't print anything neither in server.log, nor start.log...
I created folder Test, added "Set script" with a default one - then I go to that folder - but nothing is shown in the server.log. Which action should actually call the script? When user access the folder?
Re: Scripting (start.bsh)
PostPosted:Fri Oct 14, 2011 8:01 am
by olexandr
I've found my error!
The script is run not when I access the folder, but when I upload document.