com.atlassian.confluence.pages
Class ContentTree

java.lang.Object
  extended by com.atlassian.confluence.pages.ContentTree

public class ContentTree
extends Object

A graph of ContentNodes. Its purpose is to store a hierarchy of pages (maybe a subset of the full tree) that a user can see after applying permission checks. This saves us from having to repeat permission checks every time we need to display or walk the page hierarchy.


Constructor Summary
ContentTree()
           
ContentTree(ContentNode rootNode)
          Create a ContentTree with only a single root nodel
ContentTree(List<ContentNode> rootContentNodes)
           
 
Method Summary
 void addRootNode(ContentNode contentNode)
           
 boolean equals(Object obj)
           
 void filter(List<String> ids)
          Remove all nodes in this tree whose id does not match the list passed in
 void filter(Set<Long> includedIds, Set<Long> excludedIds)
          Filters the tree according to included and excluded ids of content nodes.
 List<ContentNode> getAllContentNodes()
           
 Page getPage(long pageId)
           
 List<Page> getPages()
           
 List<ContentNode> getRootNodes()
           
 int hashCode()
           
 boolean isRootNode(ContentNode node)
           
 void removeNode(ContentNode contentNode)
           
 int size()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentTree

public ContentTree()

ContentTree

public ContentTree(ContentNode rootNode)
Create a ContentTree with only a single root nodel

Parameters:
rootNode - the only root node in this content tree

ContentTree

public ContentTree(List<ContentNode> rootContentNodes)
Method Detail

getRootNodes

public List<ContentNode> getRootNodes()

isRootNode

public boolean isRootNode(ContentNode node)

filter

public void filter(List<String> ids)
Remove all nodes in this tree whose id does not match the list passed in

Parameters:
ids - List of String representations of the ids of pages

filter

public void filter(Set<Long> includedIds,
                   Set<Long> excludedIds)
Filters the tree according to included and excluded ids of content nodes. Nodes are removed if:
  1. no ancestor is included in includedIds
  2. their closest ancestor mentioned in either list is in excludedIds
  3. they are in excludedIds

Any nodes included whose immediate parents are not included are moved to the root.

Any root nodes not mentioned at all are excluded.

If we were to make this handle hidden pages too then we'd add an extra rule:

  1. they are not visible to the current user and any of their siblings are in excludedIds

Parameters:
includedIds - ids of pages to include (including their descendants except where exclusions apply)
excludedIds - ids of pages to exclude (their descendants are also excluded except where more specific inclusions apply)

addRootNode

public void addRootNode(ContentNode contentNode)

removeNode

public void removeNode(ContentNode contentNode)

getAllContentNodes

public List<ContentNode> getAllContentNodes()

getPage

public Page getPage(long pageId)
Parameters:
pageId - the id of the required page
Returns:
the Page from the ContentTree or null if there is no page with that id in the ContentTree

getPages

public List<Page> getPages()
Returns:
all the pages associated with the nodes in this tree

size

public int size()
Returns:
the number of nodes in this tree

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2003-2013 Atlassian. All Rights Reserved.