org.apache.lenya.cms.publication
Class DefaultDocumentIdToPathMapper

java.lang.Object
  extended by org.apache.lenya.cms.publication.DefaultDocumentIdToPathMapper
All Implemented Interfaces:
DocumentIdToPathMapper, PathToDocumentIdMapper

public class DefaultDocumentIdToPathMapper
extends java.lang.Object
implements DocumentIdToPathMapper, PathToDocumentIdMapper

Default DocumentIdToPathMapper implementation.

Version:
$Id: DefaultDocumentIdToPathMapper.java 473861 2006-11-12 03:51:14Z gregor $

Field Summary
static java.lang.String BASE_FILENAME_PREFIX
          The file name.
 
Constructor Summary
DefaultDocumentIdToPathMapper()
           
 
Method Summary
protected  java.io.File getDirectory(Publication publication, java.lang.String area)
           
 java.lang.String getDocumentId(Publication publication, java.lang.String area, java.io.File file)
          Returns the document ID for a certain file.
 java.io.File getFile(Publication publication, java.lang.String area, java.lang.String uuid, java.lang.String language)
          Compute the document-path for a given publication, area, document-uuid and language
protected  java.lang.String getFilename(java.lang.String language)
          Constructs the filename for a given language.
 java.lang.String getLanguage(java.io.File file)
          Returns the language for a certain file
 java.lang.String getPath(java.lang.String uuid, java.lang.String language)
          Compute the document-path for a given publication, area and document-uuid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASE_FILENAME_PREFIX

public static final java.lang.String BASE_FILENAME_PREFIX
The file name.

See Also:
Constant Field Values
Constructor Detail

DefaultDocumentIdToPathMapper

public DefaultDocumentIdToPathMapper()
Method Detail

getFile

public java.io.File getFile(Publication publication,
                            java.lang.String area,
                            java.lang.String uuid,
                            java.lang.String language)
Description copied from interface: DocumentIdToPathMapper
Compute the document-path for a given publication, area, document-uuid and language

Specified by:
getFile in interface DocumentIdToPathMapper
Parameters:
publication - the publication of the document
area - the area of the document
uuid - the uuid of the document
language - the language of the document
Returns:
the path to the document
See Also:
DocumentIdToPathMapper.getFile(org.apache.lenya.cms.publication.Publication, java.lang.String, java.lang.String, java.lang.String)

getDirectory

protected java.io.File getDirectory(Publication publication,
                                    java.lang.String area)

getPath

public java.lang.String getPath(java.lang.String uuid,
                                java.lang.String language)
Description copied from interface: DocumentIdToPathMapper
Compute the document-path for a given publication, area and document-uuid. The file separator is the slash (/).

Specified by:
getPath in interface DocumentIdToPathMapper
Parameters:
uuid - the UUID of the document
language - the language of the document
Returns:
the path to the document, without publication ID and area
See Also:
DocumentIdToPathMapper.getPath(java.lang.String, java.lang.String)

getFilename

protected java.lang.String getFilename(java.lang.String language)
Constructs the filename for a given language.

Parameters:
language - The language.
Returns:
A string value.

getDocumentId

public java.lang.String getDocumentId(Publication publication,
                                      java.lang.String area,
                                      java.io.File file)
                               throws DocumentDoesNotExistException
Returns the document ID for a certain file.

Specified by:
getDocumentId in interface PathToDocumentIdMapper
Parameters:
publication - The publication.
area - The area.
file - The file representing the document.
Returns:
A string.
Throws:
DocumentDoesNotExistException - when the document referenced by the file does not exist.

getLanguage

public java.lang.String getLanguage(java.io.File file)
Returns the language for a certain file

Specified by:
getLanguage in interface PathToDocumentIdMapper
Parameters:
file - the document file
Returns:
the language for the given document file or null if the file has no language.


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