Search:

Apache » Lenya
project logo
  • Project
  • Developer
  • Community
  • Version 2.0
  • Version 1.2
  • Version 1.2
    • Installation
      • Download
      • Subversion Access
      • Install Instructions
    • Tutorial
      • Introduction
      • 1. Understanding Lenya
      • 2. Installing Lenya
      • 3. Anatomy of the Pipeline
      • 4. Editing in Lenya
      • 5. Custom Navigation in Lenya
      • 6a. Mod Proxy and Lenya
      • 6b. Mod Proxy and Lenya
    • How-To
      • FAQ
      • New Publication
      • Deploy Publication
      • Look and Feel
      • Custom Resource Type
      • Adding Mime Types
      • Site Navigation
      • LDAP Authentication
      • CMS Menus
      • CMS Screens
      • Search Publications
      • External Data
      • Unit Tests
    • Components
      • Access Control
        • Basic Terms
        • Access Controllers
        • Access Controller Resolvers
        • Authenticators
        • Authorizers
        • Policies and Policy Managers
        • Accreditable Managers
        • SSL Encryption
      • Authoring
        • Adding a new document creator
        • Image Upload
        • OpenOffice
      • Deployment
        • Proxying
      • Editors
        • HTML Form Editor
        • HTML One Form Editor
        • Bitflux Editor
        • Kupu
        • Xopus
      • Layout
        • Navigation
        • XHTML templating
        • Serving static resources
        • Lenya Menubar
      • Publication
        • PageEnvelopeModule
        • Site tree
      • Resource Types
        • Resource Types
      • Revision Control
        • Revision Controller
        • RCML
        • Check In
        • Check Out
        • Revisions
        • Rollback
      • Repository
        • WebDAV Servers
      • Search
        • Searching with Lucene
      • URI Handling
        • URI Parametrizer
        • URI Scheme
        • Usecases
      • Asset Management
        • Asset Management
      • Link Management
        • Link Management
      • Meta Data
        • Meta Data Handling
      • Multilingual Documents
        • Multilingual Document Handling
      • Tasks
        • The Task Concept
        • Defining Tasks
        • The TaskAction
        • Scheduling a Task
        • Included tasks
          • AntTask
          • DefaultFilePublisher
          • StaticHTMLExporter
          • MailTask
        • Developing Tasks
      • Workflow
        • Terms
        • The State Machine
        • Configuration
        • Implementation
      • Site Management
        • Archive
        • Copy
        • Deactivate
        • Delete
        • Delete the trash
        • Move
        • Move Up/Down
        • Rename
        • Restore
    • Miscellaneous
      • Namespaces
      • Reserved Names
      • XInclude Processor
    • 1.2 API (Javadoc)

Current Event

Built with Apache Lenya

The TaskAction: Triggering a Task from the Sitemap

Table of Contents
  • Declaring the Action
  • Scheduling a Task
  • Developing Your Own Tasks

Declaring the Action

To invoke a task from a sitemap pipeline, you use a TaskAction. The task ID is handled to the action by a task parameter:


<map:components>
  ...
  <map:actions>
    <map:action name="publisher"
                src="org.lenya.cms.cocoon.acting.TaskAction">
      <task id="publish"/>
    </map:action>
  </map:actions>
  ...
</map:components>

The TaskAction collects the request parameters and forwards them to the task.


<map:match pattern="lenya/publish*">
  <map:act type="publisher">
    <map:redirect-to uri="{parent_uri}" session="true"/>
  </map:act>
  <map:redirect-to uri="publishScreen?status=failed" session="true"/>
</map:match>

You can also pass the task ID as a task-id parameter directly in the pipeline:



<map:actions>
  <map:action name="task" src="org.lenya.cms.cocoon.acting.TaskAction"/>
</map:actions>

...

<map:match pattern="lenya/publish*">
  <map:act type="task">
    <map:parameter name="task-id" value="publish-article"/>
    <map:redirect-to uri="{parent_uri}" session="true"/>
  </map:act>
  <map:redirect-to uri="publishScreen?status=failed" session="true"/>
</map:match>

Scheduling a Task

See section Scheduler .

Developing Your Own Tasks

Every task must implement the org.lenya.cms.task.Task interface.

The easiest way to develop your own task is to extend the AbstractTask class. Its parameterize() method simply replaces old parameter values with new ones. All you have to do is implementing the execute(String contextPath) method.

You may wonder why we pass the contextPath as a method parameter since we already pass it as a task parameter. This ensures that the task is always able to access the Lenya CMS directory, even if it is not created by a TaskAction or a TaskJob. Furthermore, if you enter a task in the jobs.xml file manually, you won't have to provide a hard-coded servlet-context parameter.

This feature may be subject to changes. If you have any suggestions to improve the task implementation, just contact me (Andreas Hartmann) at ah@wyona.org.

Copyright © 1999-2011 The Apache Software Foundation. All rights reserved.

Apache Lenya, Apache, and the Apache feather logo are trademarks of The Apache Software Foundation.