info.magnolia.templating.inheritance
Class DefaultInheritanceContentDecorator

java.lang.Object
  extended by info.magnolia.jcr.decoration.AbstractContentDecorator
      extended by info.magnolia.jcr.inheritance.InheritanceContentDecorator
          extended by info.magnolia.templating.inheritance.DefaultInheritanceContentDecorator
All Implemented Interfaces:
ContentDecorator, Cloneable

public class DefaultInheritanceContentDecorator
extends InheritanceContentDecorator

Provides an inheritance model that can be customized with configuration on the nodes. Inheritance can be completely turned off or inheritance of nodes or properties can be turned off separately.

The inheritance sources are found by looking at the node hierarchy, each node that qualifies as an anchor (node type is mgnl:content) and has a node that with the same sub-path as the destination node has to its nearest parent is used.

That is, for a destination node /page1/page2/main, the nearest anchor node is /page1/page2, therefor if there is a node /page1/main then that is used as a source.


Nested Class Summary
 
Nested classes/interfaces inherited from class info.magnolia.jcr.inheritance.InheritanceContentDecorator
InheritanceContentDecorator.DestinationNodeInheritanceNodeWrapper
 
Constructor Summary
DefaultInheritanceContentDecorator(javax.jcr.Node destination, InheritanceConfiguration configuration)
           
 
Method Summary
protected  javax.jcr.Node findFirstAnchor()
           
protected  boolean inheritsNodes(javax.jcr.Node node)
          Decides if a node inherits child nodes.
protected  boolean inheritsProperties(javax.jcr.Node node)
          Decides if a node inherits properties.
protected  boolean isAnchor(javax.jcr.Node node)
          True if this node is an anchor.
protected  boolean isSourceChildInherited(javax.jcr.Node node)
          Decides if a specific child node of one of the source should be inherited.
protected  javax.jcr.NodeIterator sortInheritedNodes(javax.jcr.NodeIterator destinationChildren, List<javax.jcr.NodeIterator> sourceChildren)
          Sorts the inherited nodes and provides a NodeIterator representing that order.
 
Methods inherited from class info.magnolia.jcr.inheritance.InheritanceContentDecorator
addSource, combinePropertyIterators, getDestination, isMultipleWrapEnabled, wrapNode
 
Methods inherited from class info.magnolia.jcr.decoration.AbstractContentDecorator
evaluateNode, evaluateProperty, wrapNodeIterator, wrapProperty, wrapPropertyIterator, wrapSession, wrapWorkspace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultInheritanceContentDecorator

public DefaultInheritanceContentDecorator(javax.jcr.Node destination,
                                          InheritanceConfiguration configuration)
                                   throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException
Method Detail

findFirstAnchor

protected javax.jcr.Node findFirstAnchor()
                                  throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

isAnchor

protected boolean isAnchor(javax.jcr.Node node)
                    throws javax.jcr.RepositoryException
True if this node is an anchor. By default true if this node is of type NodeTypes.Content.NAME.

Parameters:
node - the node to evaluate
Returns:
true if the node is an anchor
Throws:
javax.jcr.RepositoryException - if a problem occurs accessing the node

inheritsNodes

protected boolean inheritsNodes(javax.jcr.Node node)
                         throws javax.jcr.RepositoryException
Description copied from class: InheritanceContentDecorator
Decides if a node inherits child nodes. By default always returns true.

Overrides:
inheritsNodes in class InheritanceContentDecorator
Parameters:
node - the destination node or a source node
Returns:
true if the node inherits nodes
Throws:
javax.jcr.RepositoryException

inheritsProperties

protected boolean inheritsProperties(javax.jcr.Node node)
                              throws javax.jcr.RepositoryException
Description copied from class: InheritanceContentDecorator
Decides if a node inherits properties. By default always returns true.

Overrides:
inheritsProperties in class InheritanceContentDecorator
Parameters:
node - the destination node or a source node
Returns:
true if the node inherits properties
Throws:
javax.jcr.RepositoryException

isSourceChildInherited

protected boolean isSourceChildInherited(javax.jcr.Node node)
                                  throws javax.jcr.RepositoryException
Description copied from class: InheritanceContentDecorator
Decides if a specific child node of one of the source should be inherited. By default always returns true.

Overrides:
isSourceChildInherited in class InheritanceContentDecorator
Parameters:
node - a child of one of the source nodes
Returns:
true if the node is inherited
Throws:
javax.jcr.RepositoryException

sortInheritedNodes

protected javax.jcr.NodeIterator sortInheritedNodes(javax.jcr.NodeIterator destinationChildren,
                                                    List<javax.jcr.NodeIterator> sourceChildren)
                                             throws javax.jcr.RepositoryException
Description copied from class: InheritanceContentDecorator
Sorts the inherited nodes and provides a NodeIterator representing that order. By default orders nodes from the top-most source first and nodes from the destination last.

Overrides:
sortInheritedNodes in class InheritanceContentDecorator
Parameters:
destinationChildren - children of the destination node
sourceChildren - children of each of the source nodes in bottom-up order
Returns:
Throws:
javax.jcr.RepositoryException


Copyright © 2003-2013 Magnolia International Ltd.. All Rights Reserved.