Longhorn
From OkapiWiki
Contents |
Overview
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.
The distribution also includes a client library to access the Longhorn Web services.
Download and Installation
- Stable release: http://code.google.com/p/okapi/downloads/list
- Development release (snapshot): http://okapi.opentag.com/snapshots
To install Longhorn:
- Unzip the distribution file on your server.
- Follow the instructions provided with the
readmefile of the distribution. - Longhorn requires Java 1.6.
Functionality
To process files with Longhorn these steps are required:
- Create a temporary project
- Upload a Batch Configuration file into that project
- Upload the input files into that project
- Execute the project
- Download the output files
- Delete the project
Usage
There are three ways to access Longhorns functionality. There is
- a REST interface,
- a Java API and
- an HTML client.
They can be used as described below.
REST-Interface
Longhorn can be accessed directly via HTTP methods:
- POST http://{host}/okapi-longhorn/projects
- Creates a new temporary project and returns its URI (e.g.
http://localhost/okapi-longhorn/projects/1) - POST http://{host}/okapi-longhorn/projects/1/batchConfiguration
- Uploads a Batch Configuration file
- 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)
- PUT http://{host}/okapi-longhorn/projects/1/inputFiles/help.html
- Uploads a file that will have the name 'help.html'
- POST http://{host}/okapi-longhorn/projects/1/tasks/execute
- Executes the Batch Configuration on the uploaded input files
- 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'
- GET http://{host}/okapi-longhorn/projects/1/outputFiles
- Returns a list of the output files generated
- GET http://{host}/okapi-longhorn/projects/1/outputFiles/help.out.html
- Accesses the output file 'help.out.html' directly
- GET http://{host}/okapi-longhorn/projects/1/outputFiles.zip
- Returns all output files in a zip archive
- DEL http://{host}/okapi-longhorn/projects/1
- Deletes the project
- GET http://{host}/okapi-longhorn/projects
- Returns a list of all projects on the server
Java-API
The API is distributed as a .jar file in the Longhorn distribution package. You can also build it from the Okapi source code via Maven from the project lib-longhorn-api.
Sample Code
LonghornService ws = new RESTService(new URI("http://localhost:9095/okapi-longhorn"));
// Create project
LonghornProject proj = ws.createProject();
// Post batch configuration
File bconfFile = new File("C:\\setup.bconf");
proj.addBatchConfiguration(bconfFile);
// Send input files
// First by single upload...
File file1 = new File("C:\\help.html");
// * in the root directory
proj.addInputFile(file1, file1.getName());
// * and in a sub-directory
proj.addInputFile(file1, "samefile/" + file1.getName());
// ...then by package upload
File inputPackage = new File("C:\\more_files.zip");
proj.addInputFilesFromZip(inputPackage);
// Execute pipeline
// Languages don't matter
proj.executePipeline();
// Languages matter
proj.executePipeline("en-US", "de-DE");
// Get output files
ArrayList<LonghornFile> outputFiles = proj.getOutputFiles();
// Does the fetching of files work?
for (LonghornFile of : outputFiles) {
InputStream is = of.openStream();
//TODO save InputStream to local file
}
// Delete project
proj.delete();
HTML-Client
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.
Limitations
- Longhorn is BETA.
