org.apache.lenya.cms.publication
Class DefaultDocumentBuilder

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.lenya.cms.publication.DefaultDocumentBuilder
All Implemented Interfaces:
org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, org.apache.avalon.framework.thread.ThreadSafe, DocumentBuilder

public class DefaultDocumentBuilder
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements DocumentBuilder, org.apache.avalon.framework.service.Serviceable, org.apache.avalon.framework.thread.ThreadSafe

Default document builder implementation.

Version:
$Id: DefaultDocumentBuilder.java 507914 2007-02-15 12:15:30Z andreas $

Field Summary
protected  org.apache.avalon.framework.service.ServiceManager manager
           
 
Fields inherited from interface org.apache.lenya.cms.publication.DocumentBuilder
ROLE
 
Constructor Summary
DefaultDocumentBuilder()
          Ctor.
 
Method Summary
protected  java.lang.String buildCanonicalDocumentUrl(DocumentFactory factory, DocumentLocator locator)
          Builds the canonical document URL.
 java.lang.String buildCanonicalUrl(DocumentFactory factory, DocumentLocator doc)
          Builds an URL corresponding to a CMS document.
protected  java.lang.String getExtension(java.lang.String url)
          Returns the extension of a URL.
protected  java.lang.String getLanguage(java.lang.String urlWithoutSuffix)
          Returns the language of a URL.
 DocumentLocator getLocator(DocumentFactory factory, java.lang.String webappUrl)
          Returns a document for a web application URL.
protected  DocumentLocator getLocatorWithoutCheck(DocumentFactory factory, java.lang.String webappUrl)
          Creates a document locator for a webapp URL without checking if the webapp URL refers to a locator first.
 boolean isDocument(DocumentFactory factory, java.lang.String url)
          Checks if an URL corresponds to a CMS document.
 boolean isValidDocumentName(java.lang.String documentName)
          Checks if a document name is valid.
protected  java.lang.String removeExtensions(java.lang.String url)
          Removes all "."
 void service(org.apache.avalon.framework.service.ServiceManager manager)
           
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

manager

protected org.apache.avalon.framework.service.ServiceManager manager
Constructor Detail

DefaultDocumentBuilder

public DefaultDocumentBuilder()
Ctor.

Method Detail

service

public void service(org.apache.avalon.framework.service.ServiceManager manager)
Specified by:
service in interface org.apache.avalon.framework.service.Serviceable
See Also:
Serviceable.service(org.apache.avalon.framework.service.ServiceManager)

removeExtensions

protected java.lang.String removeExtensions(java.lang.String url)
Removes all "."-separated extensions from a URL (e.g., /foo.print.html is transformed to /foo).

Parameters:
url - The URL to trim.
Returns:
A URL string.

getLanguage

protected java.lang.String getLanguage(java.lang.String urlWithoutSuffix)
Returns the language of a URL.

Parameters:
urlWithoutSuffix - The URL without the suffix.
Returns:
A string.

getExtension

protected java.lang.String getExtension(java.lang.String url)
Returns the extension of a URL.

Parameters:
url - The URL.
Returns:
The extension.

isDocument

public boolean isDocument(DocumentFactory factory,
                          java.lang.String url)
                   throws DocumentBuildException
Description copied from interface: DocumentBuilder
Checks if an URL corresponds to a CMS document.

Specified by:
isDocument in interface DocumentBuilder
Parameters:
factory - The document factory.
url - The URL of the form /{publication-id}/...
Returns:
A boolean value.
Throws:
DocumentBuildException - when something went wrong.
See Also:
DocumentBuilder.isDocument(DocumentFactory, String)

buildCanonicalDocumentUrl

protected java.lang.String buildCanonicalDocumentUrl(DocumentFactory factory,
                                                     DocumentLocator locator)
Builds the canonical document URL.

Parameters:
factory - The document factory.
locator - The document locator.
Returns:
A string.

buildCanonicalUrl

public java.lang.String buildCanonicalUrl(DocumentFactory factory,
                                          DocumentLocator doc)
Description copied from interface: DocumentBuilder
Builds an URL corresponding to a CMS document.

Specified by:
buildCanonicalUrl in interface DocumentBuilder
Parameters:
factory - The document factory.
doc - The locator.
Returns:
a String The corresponding URL.

getLocator

public DocumentLocator getLocator(DocumentFactory factory,
                                  java.lang.String webappUrl)
                           throws DocumentBuildException
Description copied from interface: DocumentBuilder
Returns a document for a web application URL.

Specified by:
getLocator in interface DocumentBuilder
Parameters:
factory - The factory.
webappUrl - The web application URL.
Returns:
A document identifier.
Throws:
DocumentBuildException - if an error occurs.

getLocatorWithoutCheck

protected DocumentLocator getLocatorWithoutCheck(DocumentFactory factory,
                                                 java.lang.String webappUrl)
                                          throws DocumentBuildException
Creates a document locator for a webapp URL without checking if the webapp URL refers to a locator first.

Parameters:
factory - The document factory.
webappUrl - The webapp URL.
Returns:
A document locator or null if the URL doesn't refer to a locator.
Throws:
DocumentBuildException - if an error occurs.

isValidDocumentName

public boolean isValidDocumentName(java.lang.String documentName)
Description copied from interface: DocumentBuilder
Checks if a document name is valid.

Specified by:
isValidDocumentName in interface DocumentBuilder
Parameters:
documentName - The document name.
Returns:
A boolean value.
See Also:
DocumentBuilder.isValidDocumentName(java.lang.String)


Copyright © 1999-2006 Apache Software Foundation. All Rights Reserved.