<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://okapiframework.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jpaulhan</id>
	<title>Okapi Framework - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://okapiframework.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jpaulhan"/>
	<link rel="alternate" type="text/html" href="http://okapiframework.org/wiki/index.php/Special:Contributions/Jpaulhan"/>
	<updated>2026-05-24T21:30:20Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.38.2</generator>
	<entry>
		<id>http://okapiframework.org/wiki/index.php?title=Longhorn&amp;diff=636</id>
		<title>Longhorn</title>
		<link rel="alternate" type="text/html" href="http://okapiframework.org/wiki/index.php?title=Longhorn&amp;diff=636"/>
		<updated>2016-11-21T12:24:51Z</updated>

		<summary type="html">&lt;p&gt;Jpaulhan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
Longhorn is a server application that allows you to execute Batch Configurations remotely on any set of input files. Batch Configurations which include pre-defined pipelines and filter configurations, can be exported from [[Rainbow]].&lt;br /&gt;
&lt;br /&gt;
The distribution also includes a client library to access the Longhorn Web services.&lt;br /&gt;
&lt;br /&gt;
==Download and Installation==&lt;br /&gt;
&lt;br /&gt;
* '''Stable release: http://bintray.com/okapi/Distribution/Longhorn&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;del&amp;gt;Development release (snapshot): http://okapiframework.org/snapshots&amp;lt;/del&amp;gt;  Development snapshots are not currently available.&lt;br /&gt;
&lt;br /&gt;
To install Longhorn:&lt;br /&gt;
&lt;br /&gt;
* Unzip the distribution file on your server.&lt;br /&gt;
* Follow the instructions provided with the &amp;lt;code&amp;gt;readme&amp;lt;/code&amp;gt; file of the distribution.&lt;br /&gt;
* Starting with m24, Longhorn requires Java 1.7.&lt;br /&gt;
&lt;br /&gt;
==Functionality==&lt;br /&gt;
&lt;br /&gt;
To process files with Longhorn these steps are required:&lt;br /&gt;
# Create a temporary project&lt;br /&gt;
# Upload a Batch Configuration file into that project&lt;br /&gt;
# Upload the input files into that project&lt;br /&gt;
# Execute the project&lt;br /&gt;
# Download the output files&lt;br /&gt;
# Delete the project&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
There are three ways to access Longhorns functionality. There is&lt;br /&gt;
* a REST interface,&lt;br /&gt;
* a Java API and&lt;br /&gt;
* an HTML client.&lt;br /&gt;
&lt;br /&gt;
They can be used as described below.&lt;br /&gt;
&lt;br /&gt;
===REST-Interface===&lt;br /&gt;
&lt;br /&gt;
Longhorn can be accessed directly via HTTP methods:&lt;br /&gt;
;POST http://{host}/okapi-longhorn/projects/new : Creates a new temporary project and returns its URI (e.g. &amp;lt;code&amp;gt;http://localhost/okapi-longhorn/projects/1&amp;lt;/code&amp;gt;)&lt;br /&gt;
;POST http://{host}/okapi-longhorn/projects/1/batchConfiguration : Uploads a Batch Configuration file&lt;br /&gt;
;POST http://{host}/okapi-longhorn/projects/1/inputFiles.zip : Adds input files as a zip archive (the zip will be extracted and the included files will be used as input files)&lt;br /&gt;
;PUT http://{host}/okapi-longhorn/projects/1/inputFiles/help.html : Uploads a file that will have the name 'help.html'&lt;br /&gt;
;GET http://{host}/okapi-longhorn/projects/1/inputFiles/help.html: Retrieve an input file that was previously added with PUT or POST&lt;br /&gt;
;POST http://{host}/okapi-longhorn/projects/1/tasks/execute : Executes the Batch Configuration on the uploaded input files&lt;br /&gt;
;POST http://{host}/okapi-longhorn/projects/1/tasks/execute/en-US/de-DE : Executes the Batch Configuration on the uploaded input files with the source language set to 'en-US' and the target language set to 'de-DE'&lt;br /&gt;
;POST http://{host}/okapi-longhorn/projects/1/tasks/execute/en-US?targets=de-DE&amp;amp;targets=fr-FR : Executes the Batch Configuration on the uploaded input files with the source language set to 'en-US' and multiple target languages, 'de-DE' and 'fr-FR'&lt;br /&gt;
;GET http://{host}/okapi-longhorn/projects/1/outputFiles : Returns a list of the output files generated&lt;br /&gt;
;GET http://{host}/okapi-longhorn/projects/1/outputFiles/help.out.html : Accesses the output file 'help.out.html' directly&lt;br /&gt;
;GET http://{host}/okapi-longhorn/projects/1/outputFiles.zip : Returns all output files in a zip archive&lt;br /&gt;
;DEL http://{host}/okapi-longhorn/projects/1 : Deletes the project&lt;br /&gt;
;GET http://{host}/okapi-longhorn/projects : Returns a list of all projects on the server&lt;br /&gt;
&lt;br /&gt;
===REST-Interface Sample code: Python===&lt;br /&gt;
&lt;br /&gt;
This example works with the requests package - minidom is used to parse the XML project list.&lt;br /&gt;
&lt;br /&gt;
    import requests&lt;br /&gt;
    from xml.dom import minidom&lt;br /&gt;
&lt;br /&gt;
    url = 'http://localhost:8080/okapi-longhorn/'&lt;br /&gt;
&lt;br /&gt;
Code to create a new project&lt;br /&gt;
&lt;br /&gt;
    r = requests.post(url+'projects/new')&lt;br /&gt;
    print r.text&lt;br /&gt;
&lt;br /&gt;
Code to '''list''' existing projects (i.e.: to check if the project was created, and to get the ID of the last project)&lt;br /&gt;
&lt;br /&gt;
    r = requests.get(url+'projects/')&lt;br /&gt;
&lt;br /&gt;
    xmlstring = minidom.parseString(r.text)&lt;br /&gt;
    itemlist = xmlstring.getElementsByTagName('e')&lt;br /&gt;
    lastproject = len(itemlist)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Code to '''post''' a '''batch config file'''&lt;br /&gt;
&lt;br /&gt;
    batchfile = open('/home/user/batchconfig.bconf', 'rb')&lt;br /&gt;
    r = requests.post(url+'projects/'+str(lastproject)+'/batchConfiguration', files=dict(batchConfiguration=batchfile))&lt;br /&gt;
&lt;br /&gt;
Code to '''put''' a string as a '''file'''&lt;br /&gt;
&lt;br /&gt;
    payload = &amp;quot;hello world!&amp;quot;&lt;br /&gt;
    r = requests.put(url+'projects/'+str(lastproject)+'/inputFiles/test.txt', files=dict(inputFile=payload))&lt;br /&gt;
&lt;br /&gt;
Code to '''post''' a '''file'''&lt;br /&gt;
&lt;br /&gt;
    payload = open('/home/user/test.txt', 'rb')&lt;br /&gt;
    r = requests.post(url+'projects/'+str(lastproject)+'/inputFiles/test.txt', files=dict(inputFile=payload))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Java API===&lt;br /&gt;
&lt;br /&gt;
The API is distributed as a &amp;lt;code&amp;gt;.jar&amp;lt;/code&amp;gt; file in the Longhorn distribution package. You can also build it from the Okapi source code via Maven from the project &amp;lt;code&amp;gt;lib-longhorn-api&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Maven====&lt;br /&gt;
The API is available as a maven dependency.  Add this repository to your &amp;lt;tt&amp;gt;pom.xml&amp;lt;/tt&amp;gt;:&lt;br /&gt;
    &amp;lt;repository&amp;gt;&lt;br /&gt;
        &amp;lt;id&amp;gt;okapi-longhorn-release&amp;lt;/id&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;Okapi Longhorn Release&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;url&amp;gt;http://repository-opentag.forge.cloudbees.com/release/&amp;lt;/url&amp;gt;&lt;br /&gt;
    &amp;lt;/repository&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Along with this dependency, substituting in a valid version number (e.g, &amp;lt;tt&amp;gt;0.27&amp;lt;/tt&amp;gt;):&lt;br /&gt;
    &amp;lt;dependency&amp;gt;&lt;br /&gt;
      &amp;lt;groupId&amp;gt;net.sf.okapi.lib&amp;lt;/groupId&amp;gt;&lt;br /&gt;
      &amp;lt;artifactId&amp;gt;okapi-lib-longhorn-api&amp;lt;/artifactId&amp;gt;&lt;br /&gt;
      &amp;lt;version&amp;gt;${okapi.version}&amp;lt;/version&amp;gt;&lt;br /&gt;
    &amp;lt;/dependency&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Sample Code====&lt;br /&gt;
&lt;br /&gt;
 LonghornService ws = new RESTService(new URI(&amp;quot;http://localhost:9095/okapi-longhorn&amp;quot;));&lt;br /&gt;
 &lt;br /&gt;
 // Create project&lt;br /&gt;
 LonghornProject proj = ws.createProject();&lt;br /&gt;
 &lt;br /&gt;
 // Post batch configuration&lt;br /&gt;
 File bconfFile = new File(&amp;quot;C:\\setup.bconf&amp;quot;);&lt;br /&gt;
 proj.addBatchConfiguration(bconfFile);&lt;br /&gt;
 &lt;br /&gt;
 // Send input files&lt;br /&gt;
 &lt;br /&gt;
 // First by single upload...&lt;br /&gt;
 File file1 = new File(&amp;quot;C:\\help.html&amp;quot;);&lt;br /&gt;
 // * in the root directory&lt;br /&gt;
 proj.addInputFile(file1, file1.getName());&lt;br /&gt;
 // * and in a sub-directory&lt;br /&gt;
 proj.addInputFile(file1, &amp;quot;samefile/&amp;quot; + file1.getName());&lt;br /&gt;
 &lt;br /&gt;
 // ...then by package upload&lt;br /&gt;
 File inputPackage = new File(&amp;quot;C:\\more_files.zip&amp;quot;);&lt;br /&gt;
 proj.addInputFilesFromZip(inputPackage);&lt;br /&gt;
 &lt;br /&gt;
 // Execute pipeline&lt;br /&gt;
 // Languages don't matter&lt;br /&gt;
 proj.executePipeline();&lt;br /&gt;
 // Languages matter&lt;br /&gt;
 proj.executePipeline(&amp;quot;en-US&amp;quot;, &amp;quot;de-DE&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
 // Get output files&lt;br /&gt;
 ArrayList&amp;lt;LonghornFile&amp;gt; outputFiles = proj.getOutputFiles();&lt;br /&gt;
 &lt;br /&gt;
 // Does the fetching of files work?&lt;br /&gt;
 for (LonghornFile of : outputFiles) {&lt;br /&gt;
 	InputStream is = of.openStream();&lt;br /&gt;
 	//TODO save InputStream to local file&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 // Delete project&lt;br /&gt;
 proj.delete();&lt;br /&gt;
&lt;br /&gt;
===HTML-Client===&lt;br /&gt;
&lt;br /&gt;
You can create projects and upload/download files via an integrated HTML client, too. Uploading input files (and downloading output files) as a zip archive is currently not implemented for the HTML client.&lt;br /&gt;
&lt;br /&gt;
[[File:longhorn_html_client.png]]&lt;br /&gt;
&lt;br /&gt;
===Configuration===&lt;br /&gt;
Since Okapi M22 Okapi Longhorn can be build to run multiple instances on one server.&lt;br /&gt;
You can adjust the build so that it is possible to run multiple Longhorn instances in one JBoss application server. Therefore, the build must be called with an additional parameter:&lt;br /&gt;
&lt;br /&gt;
 mvn clean verify -DuseUniqueContextRoot&lt;br /&gt;
&lt;br /&gt;
====Configure working directory path====&lt;br /&gt;
Longhorn has 2 options to configure the working directory of longhorn (sort by priority): &lt;br /&gt;
#system parameter &amp;quot;LONGHORN_WORKDIR&amp;quot;&lt;br /&gt;
#configuration file in user.home &amp;quot;/okapi-longhorn-configuration.xml&amp;quot;&lt;br /&gt;
If nothing is defined, the working-directory is in user.home in folder &amp;quot;Okapi-Longhorn-Files&amp;quot;.&lt;br /&gt;
Longhorn configuration file example:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;longhorn-config&amp;gt;&lt;br /&gt;
     &amp;lt;use-unique-working-directory&amp;gt;True&amp;lt;/use-unique-working-directory&amp;gt;&lt;br /&gt;
     &amp;lt;working-directory&amp;gt;D:\testData\longhorn-files&amp;lt;/working-directory&amp;gt;&lt;br /&gt;
 &amp;lt;/longhorn-config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Configuration Options====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! option&lt;br /&gt;
! description&lt;br /&gt;
! data type&lt;br /&gt;
|-&lt;br /&gt;
| working-directory&lt;br /&gt;
| path of the working directory&lt;br /&gt;
| string&lt;br /&gt;
|-&lt;br /&gt;
| use-unique-working-directory&lt;br /&gt;
| if set to true the version of longhorn will be added to working directory name&lt;br /&gt;
e.g path/to/working/directory_M0.21&lt;br /&gt;
| boolean(True or False)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Longhorn]]&lt;/div&gt;</summary>
		<author><name>Jpaulhan</name></author>
	</entry>
</feed>