org.apache.lenya.cms.publication
Class DocumentHelper

java.lang.Object
  extended by org.apache.lenya.cms.publication.DocumentHelper

public class DocumentHelper
extends java.lang.Object

Helper class to handle documents from XSP.


Constructor Summary
DocumentHelper(java.util.Map objectModel)
          Ctor.
 
Method Summary
 java.lang.String getCompleteParentUrl()
          Returns the complete URL of the parent document.
 java.lang.String getDocumentUrl(java.lang.String documentId, java.lang.String documentArea, java.lang.String language)
          Creates a document URL.
static Document getExistingLanguageVersion(Document document)
          Returns an existing language version of a document.
static Document getExistingLanguageVersion(Document document, java.lang.String preferredLanguage)
          Returns an existing language version of a document.
static Document getParentDocument(Document document)
          Returns the parent document of a document in the same language.
 java.lang.String getSourceUri(Document document)
          Returns e.g. context:/lenya/pubs/default/content/authoring/tutorial/index_en.xml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentHelper

public DocumentHelper(java.util.Map objectModel)
Ctor.

Parameters:
objectModel - The Cocoon object model.
Method Detail

getDocumentUrl

public java.lang.String getDocumentUrl(java.lang.String documentId,
                                       java.lang.String documentArea,
                                       java.lang.String language)
                                throws org.apache.cocoon.ProcessingException
Creates a document URL.
If the document ID is null, the current document ID is used.
If the document area is null, the current area is used.
If the language is null, the current language is used.

Parameters:
documentId - The target document ID.
documentArea - The target area.
language - The target language.
Returns:
A string.
Throws:
org.apache.cocoon.ProcessingException - if something went wrong.

getCompleteParentUrl

public java.lang.String getCompleteParentUrl()
                                      throws org.apache.cocoon.ProcessingException
Returns the complete URL of the parent document. If the document is a top-level document, the /index document is chosen. If the parent does not exist in the appropriate language, the default language is chosen.

Returns:
A string.
Throws:
org.apache.cocoon.ProcessingException - when something went wrong.

getExistingLanguageVersion

public static Document getExistingLanguageVersion(Document document)
                                           throws DocumentException
Returns an existing language version of a document. If the document exists in the default language, the default language version is returned. Otherwise, a random language version is returned. If no language version exists, a DocumentException is thrown.

Parameters:
document - The document.
Returns:
A document.
Throws:
DocumentException - when an error occurs.

getExistingLanguageVersion

public static Document getExistingLanguageVersion(Document document,
                                                  java.lang.String preferredLanguage)
                                           throws DocumentException
Returns an existing language version of a document. If the document exists in the preferred language, this version is returned. Otherwise, if the document exists in the default language, the default language version is returned. Otherwise, a random language version is returned. If no language version exists, a DocumentException is thrown.

Parameters:
document - The document.
preferredLanguage - The preferred language.
Returns:
A document.
Throws:
DocumentException - when an error occurs.

getParentDocument

public static Document getParentDocument(Document document)
                                  throws org.apache.cocoon.ProcessingException
Returns the parent document of a document in the same language.

Parameters:
document - The document.
Returns:
A document or null if the document parameter is a top-level document.
Throws:
org.apache.cocoon.ProcessingException - when the parent document could not be created.

getSourceUri

public java.lang.String getSourceUri(Document document)
Returns e.g. context:/lenya/pubs/default/content/authoring/tutorial/index_en.xml

Parameters:
document - The document to calculate the path for.
Returns:
The path of a document within Lenya (excluding the servlet context).


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