org.apache.lenya.cms.publication
Class DefaultSiteTree

java.lang.Object
  extended by org.apache.lenya.cms.publication.DefaultSiteTree
All Implemented Interfaces:
LastModified, SiteTree

public class DefaultSiteTree
extends java.lang.Object
implements SiteTree, LastModified

Default Sitetree implementation


Field Summary
static java.lang.String SITE_TREE_FILENAME
           
 
Fields inherited from interface org.apache.lenya.cms.publication.SiteTree
NAMESPACE_URI
 
Constructor Summary
  DefaultSiteTree(java.io.File treefile)
          Deprecated. this constructor will be private in the future
protected DefaultSiteTree(java.io.File pubDir, java.lang.String area)
          Create a DefaultSiteTree
  DefaultSiteTree(java.lang.String treefilename)
          Deprecated. use the DefaultSiteTree(File pubDir, String area) constructor instead.
 
Method Summary
 void addLabel(java.lang.String documentId, Label label)
          (non-Javadoc)
 void addNode(SiteTreeNode node)
          (non-Javadoc)
 void addNode(SiteTreeNode node, java.lang.String refDocumentId)
          (non-Javadoc)
 void addNode(java.lang.String documentid, Label[] labels, boolean visibleInNav, java.lang.String href, java.lang.String suffix, boolean link)
          (non-Javadoc)
 void addNode(java.lang.String documentId, Label[] labels, boolean visibleInNav, java.lang.String href, java.lang.String suffix, boolean link, java.lang.String refDocumentId)
          (non-Javadoc)
 void addNode(java.lang.String parentid, java.lang.String id, Label[] labels)
          (non-Javadoc)
 void addNode(java.lang.String parentid, java.lang.String id, Label[] labels, boolean visibleInNav)
          (non-Javadoc)
 void addNode(java.lang.String parentid, java.lang.String id, Label[] labels, boolean visibleInNav, java.lang.String href, java.lang.String suffix, boolean link)
          (non-Javadoc)
 void addNode(java.lang.String parentid, java.lang.String id, Label[] labels, boolean visibleInNav, java.lang.String href, java.lang.String suffix, boolean link, java.lang.String refDocumentId)
          (non-Javadoc)
protected  void checkModified()
          Checks if the tree file has been modified externally and reloads the site tree.
 void copy(SiteTreeNode src, SiteTreeNode dst, java.lang.String newId, java.lang.String followingSibling)
          Copy a node with all its child node.
 org.w3c.dom.Document createDocument()
          Create a new DefaultSiteTree xml document.
 void deleteNode(java.lang.String documentId)
          Removes the node corresponding to the given document-id from the tree.
protected  org.w3c.dom.Node findNode(org.w3c.dom.Node node, java.util.List ids)
          Find a node in a subtree.
 long getLastModified()
          Get the last time a modification occured to this object.
 SiteTreeNode getNode(java.lang.String documentId)
          Return the Node for a given document-id.
 SiteTreeNode[] getTopNodes()
          Return the top level nodes in the sitetree.
 void importSubtree(SiteTreeNode newParent, SiteTreeNode subtreeRoot, java.lang.String newid, java.lang.String refDocumentId)
          (non-Javadoc)
 void move(SiteTreeNode src, SiteTreeNode dst, java.lang.String newId, java.lang.String followingSibling)
          Move a node with all its child node.
 void moveDown(java.lang.String documentid)
          Move down the node amongst its siblings.
 void moveUp(java.lang.String documentid)
          Move up the node amongst its siblings.
 void removeLabel(java.lang.String documentId, Label label)
          (non-Javadoc)
 SiteTreeNode removeNode(java.lang.String documentId)
          (non-Javadoc)
 void save()
          (non-Javadoc)
 void setLabel(java.lang.String documentId, Label label)
          Sets a label of an existing node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SITE_TREE_FILENAME

public static final java.lang.String SITE_TREE_FILENAME
See Also:
Constant Field Values
Constructor Detail

DefaultSiteTree

protected DefaultSiteTree(java.io.File pubDir,
                          java.lang.String area)
                   throws SiteTreeException
Create a DefaultSiteTree

Parameters:
pubDir - the publication directory
area - the area
Throws:
SiteTreeException - if an error occurs

DefaultSiteTree

public DefaultSiteTree(java.lang.String treefilename)
                throws SiteTreeException
Deprecated. use the DefaultSiteTree(File pubDir, String area) constructor instead.

Create a DefaultSiteTree from a filename.

Parameters:
treefilename - file name of the tree
Throws:
SiteTreeException - if an error occurs

DefaultSiteTree

public DefaultSiteTree(java.io.File treefile)
                throws SiteTreeException
Deprecated. this constructor will be private in the future

Create a DefaultSiteTree from a file.

Parameters:
treefile - the file containing the tree
Throws:
SiteTreeException - if an error occurs
Method Detail

checkModified

protected void checkModified()
Checks if the tree file has been modified externally and reloads the site tree.

Throws:
SiteTreeException - when something went wrong.

createDocument

public org.w3c.dom.Document createDocument()
                                    throws javax.xml.parsers.ParserConfigurationException
Create a new DefaultSiteTree xml document.

Returns:
the new site document
Throws:
javax.xml.parsers.ParserConfigurationException - if an error occurs

findNode

protected org.w3c.dom.Node findNode(org.w3c.dom.Node node,
                                    java.util.List ids)
Find a node in a subtree. The search is started at the given node. The list of ids contains the document-id split by "/".

Parameters:
node - where to start the search
ids - list of node ids
Returns:
the node that matches the path given in the list of ids

addNode

public void addNode(SiteTreeNode node,
                    java.lang.String refDocumentId)
             throws SiteTreeException
(non-Javadoc)

Specified by:
addNode in interface SiteTree
Parameters:
node - the SiteTreeNode that is to be added
refDocumentId - document-id of the node, before which the new node will be inserted.
Throws:
SiteTreeException - if the addition failed
See Also:
SiteTree.addNode(org.apache.lenya.cms.publication.SiteTreeNode, java.lang.String)

addNode

public void addNode(java.lang.String parentid,
                    java.lang.String id,
                    Label[] labels,
                    boolean visibleInNav)
             throws SiteTreeException
(non-Javadoc)

Specified by:
addNode in interface SiteTree
Parameters:
parentid - where the node is to be added
id - e.g. "concepts"
labels - the labels of the node that is to be added
Throws:
SiteTreeException - if the addition failed
See Also:
org.apache.lenya.cms.publication.SiteTree#addNode(java.lang.String, java.lang.String, org.apache.lenya.cms.publication.Label[])

addNode

public void addNode(java.lang.String parentid,
                    java.lang.String id,
                    Label[] labels)
             throws SiteTreeException
(non-Javadoc)

Throws:
SiteTreeException
See Also:
SiteTree.addNode(java.lang.String, java.lang.String, org.apache.lenya.cms.publication.Label[], boolean)

addNode

public void addNode(SiteTreeNode node)
             throws SiteTreeException
(non-Javadoc)

Specified by:
addNode in interface SiteTree
Parameters:
node - the SiteTreeNode that is to be added
Throws:
SiteTreeException - if the addition failed
See Also:
SiteTree.addNode(org.apache.lenya.cms.publication.SiteTreeNode)

addNode

public void addNode(java.lang.String documentId,
                    Label[] labels,
                    boolean visibleInNav,
                    java.lang.String href,
                    java.lang.String suffix,
                    boolean link,
                    java.lang.String refDocumentId)
             throws SiteTreeException
(non-Javadoc)

Specified by:
addNode in interface SiteTree
Parameters:
documentId - the document-id of the new node. From this the parent-id and the id are computed
labels - the labels
href - the href
suffix - the suffix
link - the link
refDocumentId - document-id of the node, before which the new node will be inserted.
Throws:
SiteTreeException - if the addition failed
See Also:
org.apache.lenya.cms.publication.SiteTree#addNode(java.lang.String, org.apache.lenya.cms.publication.Label[], java.lang.String, java.lang.String, boolean, java.lang.String)

addNode

public void addNode(java.lang.String documentid,
                    Label[] labels,
                    boolean visibleInNav,
                    java.lang.String href,
                    java.lang.String suffix,
                    boolean link)
             throws SiteTreeException
(non-Javadoc)

Specified by:
addNode in interface SiteTree
Parameters:
documentid - the document-id of the new node. From this the parent-id and the id are computed
labels - the labels
href - the href
suffix - the suffix
link - the link
Throws:
SiteTreeException - if the addition failed
See Also:
org.apache.lenya.cms.publication.SiteTree#addNode(java.lang.String, org.apache.lenya.cms.publication.Label[], java.lang.String, java.lang.String, boolean)

addNode

public void addNode(java.lang.String parentid,
                    java.lang.String id,
                    Label[] labels,
                    boolean visibleInNav,
                    java.lang.String href,
                    java.lang.String suffix,
                    boolean link)
             throws SiteTreeException
(non-Javadoc)

Specified by:
addNode in interface SiteTree
Parameters:
parentid - the node where the new node is to be inserted
id - the node id
labels - the labels
visibleInNav - the visibility of a node in the navigation. It is meant to hide specific nodes within the "public" navigation whereas the node is visible within the info/site area.
href - the href of the new node (internal and external references)
suffix - the suffix of the new node
link - Visibility of link respectively href. It is meant to support "grouping" nodes in the navigation which do not relate to a document (internal) or external link (www).
Throws:
SiteTreeException - if the addition failed
See Also:
org.apache.lenya.cms.publication.SiteTree#addNode(java.lang.String, java.lang.String, org.apache.lenya.cms.publication.Label[], java.lang.String, java.lang.String, boolean)

addNode

public void addNode(java.lang.String parentid,
                    java.lang.String id,
                    Label[] labels,
                    boolean visibleInNav,
                    java.lang.String href,
                    java.lang.String suffix,
                    boolean link,
                    java.lang.String refDocumentId)
             throws SiteTreeException
(non-Javadoc)

Specified by:
addNode in interface SiteTree
Parameters:
parentid - the node where the new node is to be inserted
id - the node id
labels - the labels
visibleInNav - the visibility of a node in the navigation
href - the href of the new node
suffix - the suffix of the new node
link - the link
refDocumentId - document-id of the node, before which the new node will be inserted.
Throws:
SiteTreeException - if the addition failed
See Also:
org.apache.lenya.cms.publication.SiteTree#addNode(java.lang.String, java.lang.String, org.apache.lenya.cms.publication.Label[], java.lang.String, java.lang.String, boolean)

addLabel

public void addLabel(java.lang.String documentId,
                     Label label)
(non-Javadoc)

Specified by:
addLabel in interface SiteTree
Parameters:
documentId - the document-id to which the label is to be added.
label - the label to add
See Also:
SiteTree.addLabel(java.lang.String, org.apache.lenya.cms.publication.Label)

removeLabel

public void removeLabel(java.lang.String documentId,
                        Label label)
(non-Javadoc)

Specified by:
removeLabel in interface SiteTree
Parameters:
documentId - the document-id from which the label is to be removed.
label - the label to remove
See Also:
SiteTree.removeLabel(java.lang.String, org.apache.lenya.cms.publication.Label)

removeNode

public SiteTreeNode removeNode(java.lang.String documentId)
(non-Javadoc)

Specified by:
removeNode in interface SiteTree
Parameters:
documentId - the document-id of the node that is to be removed
Returns:
the removed node
See Also:
SiteTree.removeNode(java.lang.String)

deleteNode

public void deleteNode(java.lang.String documentId)
                throws SiteTreeException
Description copied from interface: SiteTree
Removes the node corresponding to the given document-id from the tree.

Specified by:
deleteNode in interface SiteTree
Parameters:
documentId - the document-id of the node that is to be removed
Throws:
SiteTreeException

getNode

public SiteTreeNode getNode(java.lang.String documentId)
Description copied from interface: SiteTree
Return the Node for a given document-id.

Specified by:
getNode in interface SiteTree
Parameters:
documentId - the document-id of the node that is requested
Returns:
a SiteTreeNode if there is a node for the given document-id, null otherwise.
See Also:
SiteTree.getNode(java.lang.String)

getTopNodes

public SiteTreeNode[] getTopNodes()
Description copied from interface: SiteTree
Return the top level nodes in the sitetree.

Specified by:
getTopNodes in interface SiteTree
Returns:
the top nodes in the sitetree, or empty array if there are none
See Also:
SiteTree.getTopNodes()

moveUp

public void moveUp(java.lang.String documentid)
            throws SiteTreeException
Move up the node amongst its siblings.

Specified by:
moveUp in interface SiteTree
Parameters:
documentid - The document id for the node.
Throws:
SiteTreeException - if the moving failed.

moveDown

public void moveDown(java.lang.String documentid)
              throws SiteTreeException
Move down the node amongst its siblings.

Specified by:
moveDown in interface SiteTree
Parameters:
documentid - The document id for the node.
Throws:
SiteTreeException - if the moving failed.

importSubtree

public void importSubtree(SiteTreeNode newParent,
                          SiteTreeNode subtreeRoot,
                          java.lang.String newid,
                          java.lang.String refDocumentId)
                   throws SiteTreeException
(non-Javadoc)

Specified by:
importSubtree in interface SiteTree
Parameters:
newParent - The root of the subtree to import.
subtreeRoot - The node where the subtree shall be inserted.
newid - The new id of the inserted subtreeRoot node (to not overwrite
refDocumentId - The document-id corresponding to the reference node, before which the subtree should be inserted. If null, the subtree is inserted at the end. in case there is already a node with the same id in the tree).
Throws:
SiteTreeException - when an error occurs.
See Also:
org.apache.lenya.cms.publication.SiteTree#importSubtree(org.apache.lenya.cms.publication.SiteTreeNode, org.apache.lenya.cms.publication.SiteTreeNode, java.lang.String)

save

public void save()
          throws SiteTreeException
(non-Javadoc)

Specified by:
save in interface SiteTree
Throws:
SiteTreeException - if the saving failed
See Also:
SiteTree.save()

setLabel

public void setLabel(java.lang.String documentId,
                     Label label)
Description copied from interface: SiteTree
Sets a label of an existing node. If the label does not exist, it is added. Otherwise, the existing label is replaced.

Specified by:
setLabel in interface SiteTree
Parameters:
documentId - the document-id to which the label is to be added.
label - the label to add
See Also:
SiteTree.setLabel(java.lang.String, org.apache.lenya.cms.publication.Label)

copy

public void copy(SiteTreeNode src,
                 SiteTreeNode dst,
                 java.lang.String newId,
                 java.lang.String followingSibling)
          throws SiteTreeException
Description copied from interface: SiteTree
Copy a node with all its child node.

Specified by:
copy in interface SiteTree
Parameters:
src - Node to copy.
dst - Parent node where node will be inserted.
newId - The new id of the inserted node (in case when the node id exists already).
followingSibling - The sibling node that should follow this node (ordering), if null the node will be inserted at the end.
Throws:
SiteTreeException
See Also:
SiteTree.copy(org.apache.lenya.cms.publication.SiteTreeNode, org.apache.lenya.cms.publication.SiteTreeNode, java.lang.String, java.lang.String)

move

public void move(SiteTreeNode src,
                 SiteTreeNode dst,
                 java.lang.String newId,
                 java.lang.String followingSibling)
          throws SiteTreeException
Description copied from interface: SiteTree
Move a node with all its child node.

Specified by:
move in interface SiteTree
Parameters:
src - Node to move.
dst - Parent node where node will be inserted.
newId - The new id of the inserted node (in case when the node id exists already).
followingSibling - The sibling node that should follow the moved node (ordering), if null the node will be inserted at the end.
Throws:
SiteTreeException
See Also:
SiteTree.move(org.apache.lenya.cms.publication.SiteTreeNode, org.apache.lenya.cms.publication.SiteTreeNode, java.lang.String, java.lang.String)

getLastModified

public long getLastModified()
Description copied from interface: LastModified
Get the last time a modification occured to this object.

Specified by:
getLastModified in interface LastModified
Returns:
The last modification.
See Also:
LastModified.getLastModified()


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