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

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

public class LinkRewriter
extends java.lang.Object

Rewrite the links in a publication. This is used after renaming / moving a document.

Version:
$Id:$

Constructor Summary
LinkRewriter()
          Ctor.
 
Method Summary
protected  java.util.List getDocumentFiles(java.io.File directory)
          Returns all XML files in a specific directory.
protected  java.io.File[] getDocumentFiles(Publication publication, java.lang.String area)
          Returns all XML files in a specific area.
protected  java.lang.String getNewTargetURL(Document targetDocument, Document originalTargetDocument, Document newTargetDocument)
          Rewrites a document.
protected  boolean matches(Document targetDocument, Document originalTargetDocument)
          Checks if targetDocument refers to originalTargetDocument, to one of its language versions, to one of its descendants, or to a language version of one of the descendants.
 void rewriteLinks(Document originalTargetDocument, Document newTargetDocument, java.lang.String contextPath)
          Rewrites the links to a document and all its descendants, including all language versions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkRewriter

public LinkRewriter()
Ctor.

Method Detail

rewriteLinks

public void rewriteLinks(Document originalTargetDocument,
                         Document newTargetDocument,
                         java.lang.String contextPath)
Rewrites the links to a document and all its descendants, including all language versions.

Parameters:
originalTargetDocument - The original target document.
newTargetDocument - The new target document.
contextPath - The servlet context path.

matches

protected boolean matches(Document targetDocument,
                          Document originalTargetDocument)
Checks if targetDocument refers to originalTargetDocument, to one of its language versions, to one of its descendants, or to a language version of one of the descendants.

Parameters:
targetDocument - The target document.
originalTargetDocument - The original target document.
Returns:
A boolean value.

getNewTargetURL

protected java.lang.String getNewTargetURL(Document targetDocument,
                                           Document originalTargetDocument,
                                           Document newTargetDocument)
Rewrites a document.

Parameters:
targetDocument - The target document to rewrite.
originalTargetDocument - The original target document.
newTargetDocument - The new target document.
Returns:
A string.

getDocumentFiles

protected java.io.File[] getDocumentFiles(Publication publication,
                                          java.lang.String area)
Returns all XML files in a specific area.

Parameters:
publication - The publication.
area - The area.
Returns:
An array of files.

getDocumentFiles

protected java.util.List getDocumentFiles(java.io.File directory)
Returns all XML files in a specific directory.

Parameters:
directory - The directory.
Returns:
A list of files.


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