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.cocoon.generation.ServiceableGenerator
                  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.activity.Disposable, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, org.apache.cocoon.generation.Generator, org.apache.cocoon.sitemap.SitemapModelComponent, org.apache.cocoon.xml.XMLProducer

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

Generates a fragment of the navigation XML from the sitetree, corresponding to a given node. The node is specified by the sitemap parameters area/path. 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/path 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
          FIXME: should pass this as a parameter
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_PUBLICATION
           
protected static java.lang.String ATTR_SUFFIX
           
protected static java.lang.String ATTR_TYPE
           
protected static java.lang.String ATTR_UUID
           
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  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_INITIAL
           
protected static java.lang.String PARAM_PATH
           
protected static java.lang.String PARAM_TYPE
           
protected  java.lang.String path
          Parameter which denotes the path of the clicked node
protected static java.lang.String PREFIX
          The namespace prefix for this namespace.
protected  org.apache.lenya.cms.publication.Publication publication
           
protected  boolean showType
          Parameter which decides if the node mime types should be reported
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.ServiceableGenerator
manager
 
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(org.apache.lenya.cms.site.SiteNode node)
          Finds all the label children of a node and adds them to the nav xml.
protected  void addNodeRecursive(org.apache.lenya.cms.site.SiteNode node, java.lang.String nodeid, java.lang.String childid)
          Adds the given node, and if the node's id matched the given nodeid, it continues recursively.
protected  void addNodes(org.apache.lenya.cms.site.SiteNode[] children)
          Adds the given nodes (not recursive).
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/path is in this area.
protected  void generateFragmentRecursive(org.apache.lenya.cms.site.SiteNode[] nodes, java.lang.String path)
          Follows the path to find the way in the sitetree to the specified node and opens all folders on its way.
protected  boolean isFolder(org.apache.lenya.cms.site.SiteNode node)
          Returns a value to indicate whether a node is a folder (contains subnodes).
protected  void setNodeAttributes(org.apache.lenya.cms.site.SiteNode 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, org.apache.lenya.cms.site.SiteNode node)
          Begins a named node and calls setNodeAttributes to set its attributes.
 
Methods inherited from class org.apache.cocoon.generation.ServiceableGenerator
dispose, service
 
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 org.apache.lenya.cms.publication.Publication publication

path

protected java.lang.String path
Parameter which denotes the path 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


showType

protected boolean showType
Parameter which decides if the node mime types should be reported


areas

protected java.lang.String[] areas
FIXME: should pass this as a parameter


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_PATH

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

PARAM_INITIAL

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

PARAM_TYPE

protected static final java.lang.String PARAM_TYPE
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_PUBLICATION

protected static final java.lang.String ATTR_PUBLICATION
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_UUID

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

ATTR_LANG

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

ATTR_TYPE

protected static final java.lang.String ATTR_TYPE
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 org.apache.lenya.cms.site.SiteException,
                                org.xml.sax.SAXException,
                                org.apache.cocoon.ProcessingException
Generates a fragment of the tree which contains the children of a given node.

Throws:
org.apache.lenya.cms.site.SiteException
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException

addNodes

protected void addNodes(org.apache.lenya.cms.site.SiteNode[] children)
                 throws org.xml.sax.SAXException,
                        org.apache.lenya.cms.site.SiteException
Adds the given nodes (not recursive).

Parameters:
children -
Throws:
org.xml.sax.SAXException
org.apache.lenya.cms.site.SiteException

generateFragmentInitial

protected void generateFragmentInitial(java.lang.String siteArea)
                                throws org.apache.lenya.cms.site.SiteException,
                                       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/path is in this area.

Parameters:
siteArea -
Throws:
org.apache.lenya.cms.site.SiteException
org.xml.sax.SAXException
org.apache.cocoon.ProcessingException

generateFragmentRecursive

protected void generateFragmentRecursive(org.apache.lenya.cms.site.SiteNode[] nodes,
                                         java.lang.String path)
                                  throws org.apache.lenya.cms.site.SiteException,
                                         org.xml.sax.SAXException
Follows the path to find the way in the sitetree to the specified node and opens all folders on its way.

Parameters:
nodes -
path -
Throws:
org.apache.lenya.cms.site.SiteException
org.xml.sax.SAXException

addNodeRecursive

protected void addNodeRecursive(org.apache.lenya.cms.site.SiteNode node,
                                java.lang.String nodeid,
                                java.lang.String childid)
                         throws org.xml.sax.SAXException,
                                org.apache.lenya.cms.site.SiteException
Adds the given node, and if the node's id matched the given nodeid, it continues recursively.

Parameters:
node -
nodeid -
childid -
Throws:
org.xml.sax.SAXException
org.apache.lenya.cms.site.SiteException

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,
                         org.apache.lenya.cms.site.SiteNode node)
                  throws org.xml.sax.SAXException,
                         org.apache.lenya.cms.site.SiteException
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
org.apache.lenya.cms.site.SiteException

setNodeAttributes

protected void setNodeAttributes(org.apache.lenya.cms.site.SiteNode node)
                          throws org.xml.sax.SAXException,
                                 org.apache.lenya.cms.site.SiteException
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
org.apache.lenya.cms.site.SiteException

isFolder

protected boolean isFolder(org.apache.lenya.cms.site.SiteNode 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:
A boolean value.

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(org.apache.lenya.cms.site.SiteNode 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 $ Apache Software Foundation. All Rights Reserved.