org.apache.lenya.cms.cocoon.generation
Class SitetreeFragmentGenerator

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.xml.AbstractXMLProducer
          extended by org.apache.cocoon.generation.AbstractGenerator
              extended by org.apache.lenya.cms.cocoon.generation.SitetreeFragmentGenerator
All Implemented Interfaces:
org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.logger.LogEnabled, org.apache.cocoon.generation.Generator, org.apache.cocoon.sitemap.SitemapModelComponent, org.apache.cocoon.xml.XMLProducer

public class SitetreeFragmentGenerator
extends org.apache.cocoon.generation.AbstractGenerator

Generates a fragment of the XML from the sitetree, corresponding to a given node. The node is specified by the sitemap parameters area/documentid. If the sitemap parameter initialTree is true, the top nodes of the tree will be generated and the node given by the sitemap parameters area/documentid will be unfolded. If initialTree is false, only the children of the selected node will be generated.


Field Summary
protected  java.lang.String area
          Parameter which denotes the area of the clicked node
protected  java.lang.String[] areas
          Parameter which denotes a comma-separated list of areas, for which the xml will be generated.
protected static java.lang.String ATTR_AREA
           
protected static java.lang.String ATTR_BASE
           
protected static java.lang.String ATTR_FOLDER
           
protected static java.lang.String ATTR_HREF
           
protected static java.lang.String ATTR_ID
           
protected static java.lang.String ATTR_LABEL
           
protected static java.lang.String ATTR_LANG
           
protected static java.lang.String ATTR_LINK
           
protected static java.lang.String ATTR_SUFFIX
           
protected static java.lang.String ATTR_VISIBLEINNAV
           
protected  org.xml.sax.helpers.AttributesImpl attributes
          Convenience object, so we don't need to create an AttributesImpl for every element.
protected  java.lang.String documentid
          Parameter which denotes the documentid of the clicked node
protected  boolean initialTree
          Parameter which decides if the initial tree with the root nodes is generated
protected static java.lang.String NODE_FRAGMENT
           
protected static java.lang.String NODE_LABEL
           
protected static java.lang.String NODE_NODE
           
protected static java.lang.String NODE_SITE
           
protected static java.lang.String PARAM_AREA
           
protected static java.lang.String PARAM_AREAS
           
protected static java.lang.String PARAM_DOCUMENTID
           
protected static java.lang.String PARAM_INITIAL
           
protected static java.lang.String PREFIX
          The namespace prefix for this namespace.
protected  Publication publication
           
protected static java.lang.String URI
          The URI of the namespace of this generator.
protected static java.lang.String XML_PREFIX
           
protected static java.lang.String XML_URI
           
 
Fields inherited from class org.apache.cocoon.generation.AbstractGenerator
objectModel, parameters, resolver, source
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.generation.Generator
ROLE
 
Constructor Summary
SitetreeFragmentGenerator()
           
 
Method Summary
protected  void addLabel(java.lang.String label, java.lang.String language)
          Adds a label element of a given language.
protected  void addLabels(SiteTreeNode node)
          Finds all the label children of a node and adds them to the nav xml.
protected  void endNode(java.lang.String nodeName)
          Ends the named node.
 void generate()
           
protected  void generateFragment()
          Generates a fragment of the tree which contains the children of a given node.
protected  void generateFragmentInitial(java.lang.String siteArea)
          Generates the top node of the given area and then calls a recursive method to traverse the tree, if the node given by area/documentid is in this area.
protected  void generateFragmentRecursive(SiteTreeNode[] nodes, java.lang.String docid)
          Follows the documentid to find the way in the sitetree to the specified node and opens all folders on its way.
protected  java.lang.String isFolder(SiteTreeNode node)
          Returns a value to indicate whether a node is a folder (contains subnodes).
protected  void setNodeAttributes(SiteTreeNode node)
          Sets the attributes for a given node.
 void setup(org.apache.cocoon.environment.SourceResolver resolver, java.util.Map objectModel, java.lang.String src, org.apache.avalon.framework.parameters.Parameters par)
           
protected  void startNode(java.lang.String nodeName)
          Begins a named node and calls setNodeAttributes to set its attributes.
protected  void startNode(java.lang.String nodeName, SiteTreeNode node)
          Begins a named node and calls setNodeAttributes to set its attributes.
 
Methods inherited from class org.apache.cocoon.generation.AbstractGenerator
recycle
 
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
 

Field Detail

publication

protected Publication publication

documentid

protected java.lang.String documentid
Parameter which denotes the documentid of the clicked node


area

protected java.lang.String area
Parameter which denotes the area of the clicked node


initialTree

protected boolean initialTree
Parameter which decides if the initial tree with the root nodes is generated


areas

protected java.lang.String[] areas
Parameter which denotes a comma-separated list of areas, for which the xml will be generated.


attributes

protected org.xml.sax.helpers.AttributesImpl attributes
Convenience object, so we don't need to create an AttributesImpl for every element.


PARAM_AREA

protected static final java.lang.String PARAM_AREA
See Also:
Constant Field Values

PARAM_DOCUMENTID

protected static final java.lang.String PARAM_DOCUMENTID
See Also:
Constant Field Values

PARAM_INITIAL

protected static final java.lang.String PARAM_INITIAL
See Also:
Constant Field Values

PARAM_AREAS

protected static final java.lang.String PARAM_AREAS
See Also:
Constant Field Values

URI

protected static final java.lang.String URI
The URI of the namespace of this generator.

See Also:
Constant Field Values

XML_URI

protected static final java.lang.String XML_URI
See Also:
Constant Field Values

PREFIX

protected static final java.lang.String PREFIX
The namespace prefix for this namespace.

See Also:
Constant Field Values

XML_PREFIX

protected static final java.lang.String XML_PREFIX
See Also:
Constant Field Values

NODE_NODE

protected static final java.lang.String NODE_NODE
See Also:
Constant Field Values

NODE_LABEL

protected static final java.lang.String NODE_LABEL
See Also:
Constant Field Values

NODE_SITE

protected static final java.lang.String NODE_SITE
See Also:
Constant Field Values

NODE_FRAGMENT

protected static final java.lang.String NODE_FRAGMENT
See Also:
Constant Field Values

ATTR_ID

protected static final java.lang.String ATTR_ID
See Also:
Constant Field Values

ATTR_FOLDER

protected static final java.lang.String ATTR_FOLDER
See Also:
Constant Field Values

ATTR_AREA

protected static final java.lang.String ATTR_AREA
See Also:
Constant Field Values

ATTR_LABEL

protected static final java.lang.String ATTR_LABEL
See Also:
Constant Field Values

ATTR_VISIBLEINNAV

protected static final java.lang.String ATTR_VISIBLEINNAV
See Also:
Constant Field Values

ATTR_LINK

protected static final java.lang.String ATTR_LINK
See Also:
Constant Field Values

ATTR_BASE

protected static final java.lang.String ATTR_BASE
See Also:
Constant Field Values

ATTR_SUFFIX

protected static final java.lang.String ATTR_SUFFIX
See Also:
Constant Field Values

ATTR_HREF

protected static final java.lang.String ATTR_HREF
See Also:
Constant Field Values

ATTR_LANG

protected static final java.lang.String ATTR_LANG
See Also:
Constant Field Values
Constructor Detail

SitetreeFragmentGenerator

public SitetreeFragmentGenerator()
Method Detail

setup

public void setup(org.apache.cocoon.environment.SourceResolver resolver,
                  java.util.Map objectModel,
                  java.lang.String src,
                  org.apache.avalon.framework.parameters.Parameters par)
           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.generation.AbstractGenerator
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)

generate

public void generate()
              throws java.io.IOException,
                     org.xml.sax.SAXException,
                     org.apache.cocoon.ProcessingException
Throws:
java.io.IOException
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException
See Also:
Generator.generate()

generateFragment

protected void generateFragment()
                         throws SiteTreeException,
                                org.xml.sax.SAXException,
                                org.apache.cocoon.ProcessingException
Generates a fragment of the tree which contains the children of a given node.

Throws:
SiteTreeException
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException

generateFragmentInitial

protected void generateFragmentInitial(java.lang.String siteArea)
                                throws SiteTreeException,
                                       org.xml.sax.SAXException,
                                       org.apache.cocoon.ProcessingException
Generates the top node of the given area and then calls a recursive method to traverse the tree, if the node given by area/documentid is in this area.

Parameters:
siteArea -
Throws:
SiteTreeException
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException

generateFragmentRecursive

protected void generateFragmentRecursive(SiteTreeNode[] nodes,
                                         java.lang.String docid)
                                  throws SiteTreeException,
                                         org.xml.sax.SAXException
Follows the documentid to find the way in the sitetree to the specified node and opens all folders on its way.

Parameters:
nodes -
docid -
Throws:
SiteTreeException
org.xml.sax.SAXException

startNode

protected void startNode(java.lang.String nodeName)
                  throws org.xml.sax.SAXException
Begins a named node and calls setNodeAttributes to set its attributes.

Parameters:
nodeName - the name of the new node
Throws:
org.xml.sax.SAXException - if an error occurs while creating the node

startNode

protected void startNode(java.lang.String nodeName,
                         SiteTreeNode node)
                  throws org.xml.sax.SAXException
Begins a named node and calls setNodeAttributes to set its attributes.

Parameters:
nodeName - the name of the new node
node - The attributes are taken from this node
Throws:
org.xml.sax.SAXException - if an error occurs while creating the node

setNodeAttributes

protected void setNodeAttributes(SiteTreeNode node)
                          throws org.xml.sax.SAXException
Sets the attributes for a given node. Sets attributes id, href, folder, suffix, basic-url, language-suffix.

Parameters:
node -
Throws:
org.xml.sax.SAXException - if an error occurs while setting the attributes

isFolder

protected java.lang.String isFolder(SiteTreeNode node)
Returns a value to indicate whether a node is a folder (contains subnodes). With the incremental sitetree loading, we sometimes load nodes which are folders, but we don't load their children. But we still have to know if it's a folder or not, i.e. if it can be opened.

Parameters:
node -
Returns:
"true" or "false"

endNode

protected void endNode(java.lang.String nodeName)
                throws org.xml.sax.SAXException
Ends the named node.

Parameters:
nodeName - the name of the new node
Throws:
org.xml.sax.SAXException - if an error occurs while closing the node

addLabels

protected void addLabels(SiteTreeNode node)
                  throws org.xml.sax.SAXException
Finds all the label children of a node and adds them to the nav xml.

Parameters:
node -
Throws:
org.xml.sax.SAXException

addLabel

protected void addLabel(java.lang.String label,
                        java.lang.String language)
                 throws org.xml.sax.SAXException
Adds a label element of a given language.

Parameters:
label - the value of the label
language - the language of the label
Throws:
org.xml.sax.SAXException


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