This project has retired. For details please refer to its
Attic page.
org.apache.lenya.cms.cocoon.transformation
Class UuidToUrlTransformer
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.xml.AbstractXMLProducer
org.apache.cocoon.xml.AbstractXMLPipe
org.apache.cocoon.transformation.AbstractTransformer
org.apache.cocoon.transformation.AbstractSAXTransformer
org.apache.lenya.cms.cocoon.transformation.AbstractLinkTransformer
org.apache.lenya.cms.cocoon.transformation.UuidToUrlTransformer
- All Implemented Interfaces:
- org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, org.apache.cocoon.sitemap.SitemapModelComponent, org.apache.cocoon.transformation.Transformer, org.apache.cocoon.xml.XMLPipe, org.apache.cocoon.xml.XMLProducer, org.apache.excalibur.xml.sax.XMLConsumer, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler
public class UuidToUrlTransformer
- extends AbstractLinkTransformer
- implements org.apache.avalon.framework.activity.Disposable
UUID to URL transformer.
This transformer is applied to an XHMTL document. It processes all links following the
LinkResolver syntax which are configured using <transform/> elements
(see below).
These links are resolved using the following rules:
- The current area (obtained from the page envelope) is used.
- A URL prefix is added depending on the proxy configuration of the publication.
- If the target document does not exist and is in the authoring area, the href attribute is
removed and a class="brokenlink" attribute is added to the
<a/> element.
- If the target document does not exist and is in the live area, the
<a/>
element is removed to disable the link.
You can add the query parameter uuid2url.extension to lenya-document:
URLs to set a specific link extension.
The resulting URLs are absolute web application URLs (without the servlet context path).
$Id: LinkRewritingTransformer.java,v 1.7 2004/03/16 11:12:16 gregor
| Fields inherited from class org.apache.cocoon.transformation.AbstractSAXTransformer |
context, defaultNamespaceURI, EMPTY_ATTRIBUTES, emptyAttributes, ignoreEmptyCharacters, ignoreEventsCount, ignoreHooksCount, ignoreWhitespaces, manager, namespaceURI, objectModel, parameters, recorderStack, request, resolver, response, source, stack |
| Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer |
| Fields inherited from interface org.apache.cocoon.transformation.Transformer |
ROLE |
|
Method Summary |
void |
dispose()
|
protected Link |
getAbsoluteLink(org.apache.lenya.cms.publication.URLInformation info,
java.lang.String linkUri)
The link is constructed from the linkUri string. |
protected java.lang.String |
getExtension(org.apache.lenya.cms.publication.Document targetDocument,
java.lang.String requiredExtension)
Get the extension of a document. |
protected LinkRewriter |
getLinkRewriter()
|
protected void |
handleLink(java.lang.String linkUrl,
AbstractLinkTransformer.AttributeConfiguration config,
org.xml.sax.helpers.AttributesImpl newAttrs)
Handle a link in the source SAX stream. |
protected void |
markBrokenLink(org.xml.sax.helpers.AttributesImpl newAttrs,
java.lang.String attrName,
java.lang.String brokenUrl)
Marks a <a/> element as broken and removes href attribute. |
void |
recycle()
|
protected void |
rewriteLink(org.xml.sax.helpers.AttributesImpl newAttrs,
java.lang.String attributeName,
org.apache.lenya.cms.publication.Document targetDocument,
java.lang.String anchor,
java.lang.String queryString,
java.lang.String extension)
Rewrites a link. |
protected void |
setAttribute(org.xml.sax.helpers.AttributesImpl attr,
java.lang.String name,
java.lang.String value)
Sets the value of the href attribute. |
void |
setup(org.apache.cocoon.environment.SourceResolver _resolver,
java.util.Map _objectModel,
java.lang.String _source,
org.apache.avalon.framework.parameters.Parameters _parameters)
|
| Methods inherited from class org.apache.cocoon.transformation.AbstractSAXTransformer |
addRecorder, characters, comment, endCDATA, endDocument, endDTD, endEntity, endParametersRecording, endParametersRecording, endPrefixMapping, endRecording, endSAXRecording, endSerializedXMLRecording, endTextRecording, endTransformingElement, findPrefixMapping, getMutableAttributes, ignorableWhitespace, processingInstruction, removeRecorder, sendEndElementEvent, sendEndElementEventNS, sendEndPrefixMapping, sendEvents, sendParametersEvents, sendStartElementEvent, sendStartElementEvent, sendStartElementEventNS, sendStartElementEventNS, sendStartPrefixMapping, sendTextEvent, service, setDocumentLocator, setupTransforming, skippedEntity, startCDATA, startDocument, startDTD, startEntity, startParametersRecording, startPrefixMapping, startRecording, startSAXRecording, startSerializedXMLRecording, startTextRecording, startTransformingElement |
| Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
setConsumer, setContentHandler, setLexicalHandler |
| 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 |
| Methods inherited from interface org.apache.cocoon.xml.XMLProducer |
setConsumer |
BROKEN_ATTRIB
protected static final java.lang.String BROKEN_ATTRIB
- See Also:
- Constant Field Values
BROKEN_VALUE
protected static final java.lang.String BROKEN_VALUE
- See Also:
- Constant Field Values
EXTENSION_PARAM
protected static final java.lang.String EXTENSION_PARAM
- See Also:
- Constant Field Values
UuidToUrlTransformer
public UuidToUrlTransformer()
setup
public void setup(org.apache.cocoon.environment.SourceResolver _resolver,
java.util.Map _objectModel,
java.lang.String _source,
org.apache.avalon.framework.parameters.Parameters _parameters)
throws org.apache.cocoon.ProcessingException,
org.xml.sax.SAXException,
java.io.IOException
- Specified by:
setup in interface org.apache.cocoon.sitemap.SitemapModelComponent- Overrides:
setup in class org.apache.cocoon.transformation.AbstractSAXTransformer
- Throws:
org.apache.cocoon.ProcessingException
org.xml.sax.SAXException
java.io.IOException- See Also:
SitemapModelComponent.setup(org.apache.cocoon.environment.SourceResolver,
java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
handleLink
protected void handleLink(java.lang.String linkUrl,
AbstractLinkTransformer.AttributeConfiguration config,
org.xml.sax.helpers.AttributesImpl newAttrs)
throws java.lang.Exception
- Description copied from class:
AbstractLinkTransformer
- Handle a link in the source SAX stream.
- Overrides:
handleLink in class AbstractLinkTransformer
- Parameters:
linkUrl - The link URL.config - The attribute configuration which matched the link.newAttrs - The new attributes which will be added to the result
element.
- Throws:
java.lang.Exception - if an error occurs.
getAbsoluteLink
protected Link getAbsoluteLink(org.apache.lenya.cms.publication.URLInformation info,
java.lang.String linkUri)
throws java.net.MalformedURLException
- The link is constructed from the linkUri string. If it lacks the area or publication ID
information, these are obtained from the current URL information.
- Parameters:
info - The current URL information.linkUri - The link URI to use.
- Returns:
- A link.
- Throws:
java.net.MalformedURLException - if the linkUri parameter is malformed.
getExtension
protected java.lang.String getExtension(org.apache.lenya.cms.publication.Document targetDocument,
java.lang.String requiredExtension)
- Get the extension of a document. Caution: resolving the extension is expensive!
- Parameters:
targetDocument - The document.requiredExtension - The required extension.
- Returns:
- The required extension or, if it is null, the document's default extension.
markBrokenLink
protected void markBrokenLink(org.xml.sax.helpers.AttributesImpl newAttrs,
java.lang.String attrName,
java.lang.String brokenUrl)
throws org.apache.lenya.ac.AccessControlException
- Marks a
<a/> element as broken and removes href attribute.
- Parameters:
newAttrs - The new attributes.attrName - The attribute name.brokenUrl - The broken link URI.
- Throws:
org.apache.lenya.ac.AccessControlException - when something went wrong.
rewriteLink
protected void rewriteLink(org.xml.sax.helpers.AttributesImpl newAttrs,
java.lang.String attributeName,
org.apache.lenya.cms.publication.Document targetDocument,
java.lang.String anchor,
java.lang.String queryString,
java.lang.String extension)
throws org.apache.lenya.ac.AccessControlException
- Rewrites a link.
- Parameters:
newAttrs - The new attributes.attributeName - The name of the attribute to rewrite.targetDocument - The target document.anchor - The anchor (the string after the # character in the URL).queryString - The query string without question mark.extension - The extension to use.
- Throws:
org.apache.lenya.ac.AccessControlException - when something went wrong.
setAttribute
protected void setAttribute(org.xml.sax.helpers.AttributesImpl attr,
java.lang.String name,
java.lang.String value)
- Sets the value of the href attribute.
- Overrides:
setAttribute in class AbstractLinkTransformer
- Parameters:
attr - The attributes.name - The attribute name.value - The value.
- Throws:
java.lang.IllegalArgumentException - if the href attribute is not contained in this attributes.
dispose
public void dispose()
- Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable- Overrides:
dispose in class org.apache.cocoon.transformation.AbstractSAXTransformer
- See Also:
Disposable.dispose()
recycle
public void recycle()
- Specified by:
recycle in interface org.apache.avalon.excalibur.pool.Recyclable- Overrides:
recycle in class org.apache.cocoon.transformation.AbstractSAXTransformer
- See Also:
Recyclable.recycle()
getLinkRewriter
protected LinkRewriter getLinkRewriter()
- Specified by:
getLinkRewriter in class AbstractLinkTransformer
- Returns:
- The link rewriter used by this transformer.
Copyright © $ Apache Software Foundation. All Rights Reserved.