org.apache.lenya.cms.publication.util
Class DocumentHelper

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

public class DocumentHelper
extends java.lang.Object

Helper class to handle documents from XSP.


Constructor Summary
DocumentHelper(org.apache.avalon.framework.service.ServiceManager manager, 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 uuid, 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentHelper

public DocumentHelper(org.apache.avalon.framework.service.ServiceManager manager,
                      java.util.Map _objectModel)
Ctor.

Parameters:
manager - The service manager.
_objectModel - The Cocoon object model.
Method Detail

getDocumentUrl

public java.lang.String getDocumentUrl(java.lang.String uuid,
                                       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:
uuid - The target document UUID.
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.


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