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

URI Parametrizer

Table of Contents
  • Motivation
  • Rationale
    • Overview
    • Interfaces

Motivation

The problem of determining the doctype independent of request URI needs a flexible and yet simple solution. This is where the URI Parametrizer comes to the rescue.

Rationale

The URI Parametrizer is an action which given an arbitrary URI return a configurable number of parameters which it infers from this URI. Typical parameters include source document type, navigation location, etc. The action itself delegates to task of determining the parameters to the Cocoon sitemap, i.e. the parameters are determinined using the normal sitemap pipeline matching mechanism.

Overview

The flow of information is outlined in the following diagram:

Interfaces

The URIParametrizerAction expects an arbitrary number of parameters. Each parameter contains a key value pair which denotes the name of the parameter and the source. A typical example is as follows:

<map:act type="uriparametrizer">
  <map:parameter name="doctype"
	  value="cocoon://uri-parameter/{publication-id}/doctype"/>
  <map:parameter name="path"
	  value="cocoon://uri-parameter/{publication-id}/path"/>
  <map:generate src="cocoon:/{doctype}/{path}"/>
</map:act>

The uri-parameter prefix is a standard prefix which invokes a pipeline in the root sitemap which mounts a subsitemap in your publication with the name parameter-{parameterName}.xmap.

The action basically just issues a request back to cocoon for each parameter. It uses the URI given in the value attribute where it also adds the original request URI. So for a given request URI foo.html and the parameters given above the action basically issues to requests using the cocoon: protocol:

cocoon://uri-parameter/{publication-id}/doctype/foo.html
cocoon://uri-parameter/{publication-id}/path/foo.html

The matcher for uri-parameter in the root sitemap then tries to mount the sitemaps parameter-doctype.xmap and parameter-path.xmap in the publication. Then the reuest is matched against the parameter sitemap. Here's a very simple example of a parameter sitemap:

<?xml version="1.0"?>

<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">

  <map:components>
    <map:generators default="file"/>
    <map:transformers default="xslt"/>
    <map:readers default="resource"/>
    <map:serializers default="html"/>
    <map:matchers default="wildcard"/>
    <map:actions/>
  </map:components>

  <map:views/>

  <map:resources/>

  <map:pipelines>

    <map:pipeline>
      
      <map:match pattern="**">
	<map:generate type="serverpages" src="content/parameters/doctype.xsp">
          <map:parameter name="value" value="{1}"/>
        </map:generate>
	<map:serialize type="xml"/>
      </map:match>
      
    </map:pipeline>

  </map:pipelines>
</map:sitemap>

A more serious example could possibly include matchers using the SourceTypeAction from the Forrest Project or a HashMapAction as outlined in the SiteTree proposal.

After a match has been found the pipeline in the parameter sitemap returns an XML snippet in the following form:

<?xml version="1.0" encoding="ISO-8859-1"?>

<parameter xmlns="http://apache.org/cocoon/lenya/uri-parameters/1.0">article</parameter>

This xml is consequently parsed by the action and returned as a HashMap. Inside the action the parameters will be available under the names as they were specified in the parameters to the action.

The fact that the actual determination is delegated back to the sitemap allows for a combination of the original proposals where solutions such as Hashmap and SourceTypeAction were outlined.

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.