Date: Fri, 29 Mar 2024 03:47:58 -0400 (EDT) Message-ID: <1284078115.30024.1711698478799@lyrasis1-roc-mp1> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_30023_1082862463.1711698478799" ------=_Part_30023_1082862463.1711698478799 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
jython.jar
and the Lib
directory.unzip -d [dspace]/lib/ jython-=
installer-2.5.3.jar jython.jar Lib/
unzip -d [d=
space]/webapps/xmlui/WEB-INF/lib/ jython-installer-2.5.3.jar jy=
thon.jar Lib/
java -jar jython-installer-2.5.3= .jar --consoleNote: Installation location doesn't matter, this is not= necessary for DSpace. You can safely delete it after you retrieve
Lib
.jython.jar
and the jython =
Lib/
directory into every DSpace classpath you=
intend to use, so it must be installed in both=
[dspace]/lib
and the webapp that deploys to Tomcat (if you want=
to run from the UI) - [dspace]/webapps/xmlui/WEB-=
INF/lib/
. You can use symlinks if you wish. =
There are no special maven/pom extensions - just copy in the jar and =
Lib/
.[dspace]/config/modules/curat=
e.cfg
:script.dir=3D${dspace.dir}/ctscripts
in this directory, create a text file named "task.catalog". This is a Java properties file where lines beginning with '#' are comm=
ents. Add a line for each task you write. The syntax is following:
# logic= al task name =3D script engine name|file name|constructor invocation mytask=3Dpython|mytask.py|MyTask()
Notes:
ERROR org.dspace.curate.TaskResolver @ Script engine: 'pyt=
hon ' is not installed
script.dir=
directory"constructor invocation" is the language specific way to create an o= bject that implements the task interface - it's ClassName() for Python
<= /li>ui.tasknames
" (or groups etc)Write your task.
In the directory configured above, create your task (with the name configu=
red in "task.catalog
").
The basic requirement of any scripted task is that it implements the ScriptedTask Java interface.
So for ou=
r example, the mytask.py
file might look like this:<=
/p>
from = org.dspace.curate import ScriptedTask class MyTask(ScriptedTask): def init(self, curator, taskName): print "initializing with Jython" def performDso(self, dso): print "perform on dso" return 0 def performId(self, context, id): print "perform on id %s" % (id) return 0
Invoke the task.
You can do this the same way you would invoke any task (from command line,=
in the admin UI, etc). The advantage of scripting is that you do not need =
to restart your servlet container to test changes; each task's source =
code is reloaded when you launch the task, so you can just put the updated =
script in place.
Example of invocation from command line:
[dspace= ]/bin/dspace curate -t mytask -i 123456789/123 -r -
Note: "-r -
" means that the script's standard output =
will be directed to the console. You can read more details in the "On the c=
ommand line" chapter of the Cu=
ration System page.