Home : OpenEdit SDK : Programming OpenEdit : Workflow
Workflow
Creating a Workflow
To create a workflow, make a new file in the configuration/workflow/ directory called wfid.xml, where wfid is the id of your new workflow.Put these lines in the file:
<workflow id="wfid" name="Workflow Name"> </workflow>
The id should match exactly the filename (without the .xml) but the name can be anything.
Actions
A workflow is composed of any number of actions. Currently, these actions can either involve moving or copying files, cataloging a file into Cumulus, or sending e-mails.These action elements should be placed in the workflow in the order in which they should run.
An action element looks like this:
<action name="act_name" type=""> </action>
The name can be anything and should describe the action.
The type can be either "stream", "cumulus, or "email" and it determines the elements used within the action.
Stream Actions
A stream action moves or copies a file from one place to another.
It is written like this:
<action name="act_name" type="stream">
<from path="" type="" />
<to path="" type="" />
</action>
The from and to elements have these attributes:
type: The type can be "asset", "directory" or "ftp".
path: If the type is "asset" then no path is needed and the location is specified automatically by the asset used. Usually this is the location of the original file.
If the type is "directory", then the path is treated as a path in the filesystem.
If the type is "ftp", then the path is treated as the URL of an FTP server.
If properties are specified in the workflow or gathered form the upload form, then they may be used in this path.
Variables are written: ${variable_name} See the section on Variables
E-Mail Actions
An E-Mail action is used to send an e-mail to notify the user of the progress through the workflow.
It is written like this:
<action name="act_name" type="email">
<to>text</to>
<from>text</from>
<subject>text</subject>
<template-path>text</template-path>
</action>
The to, from, and subject elements are straightforward. Substitute in values for "text" to customize who receives the e-mail, who it comes from, and what subject it has.
The template-path element specifies a path (from the root of the webapp) to an html page which will be used as the e-mail. This html page may contain velocity code.
Cumulus Actions
A Cumulus action is used to catalog a certain file into Cumulus.
It is written like this:
<action name="act_name" type="cumulus">
<from path="" type="directory" />
<catalog-name>text</catalog-name>
<categoryid>number</categoryid>
</action>
The from element is a location, just like that used in the Stream action.
The element catalog-name will contain the name of the cumulus catalog to use.
The categoryid specifies the id of a category in the specified catalog to insert the file.
Variables
Variables may be included in most strings in the workflow. These variables will be filled with values that either come from properties in the workflow, or else possibly an html form. Currently, form variables must be added to the code by hand.
To use a variable, surround the variable name with '${' and '}'.
Example:${size}
Some variables are populated automatically. When uploading a file, ${filename} and ${filetype} will contain the file name and extension.
Example
Here's a workflow that copies an archive image to a directory and then FTP's the file to the openedit.org server. Finally, an e-mail is sent to notify that the task was completed. Some of the directory names use the 'size' variable, which we collect from an html form. The file will arrive on the FTP server with that size variable inserted into the filename.
<workflow id="oeorg" name="OpenEdit.org">
<action name="copy image" type="stream">
<from type="asset"/>
<to path="/home/work/workspace/openedit-archive/webapp/video/pickup${size}" type="directory"/>
</action>
<action name="stream" type="stream">
<from path="/home/work/workspace/openedit-archive/webapp/video/pickup${size}" type="directory"/>
<to path="openedit.org" type="ftp" user="axis" subdir="/home/axis/sub/" suffix="_${size}.mpg"/>
</action>
<action name="send task completed e-mail" type="email">
<to>axis@openedit.org</to>
<from>videos@openedit.org</from>
<subject>Task has finished ${name}</subject>
<template-path>/archive/video/finishedemail.html</template-path>
</action>
<property name="usesjobnumber">true</property>
</workflow>
