info.magnolia.cms.util
Class InheritanceContentWrapper

java.lang.Object
  extended by info.magnolia.cms.core.ContentHandler
      extended by info.magnolia.cms.core.AbstractContent
          extended by info.magnolia.cms.util.ContentWrapper
              extended by info.magnolia.cms.util.InheritanceContentWrapper
All Implemented Interfaces:
Content, Cloneable

public class InheritanceContentWrapper
extends ContentWrapper

This wrapper inherits content from the parent hierarchy. The method isAnchor() defines the anchor to which the inheritance is performed relative to. By default the anchor is a page (mgnl:content).

The inheritance is then performed as follows:

The AbstractContent.getChildren() methods merge the direct and inherited children by first adding the inherited children to the collection and then the direct children.

Version:
$Id: InheritanceContentWrapper.java 50721 2011-11-03 07:58:20Z had $
Author:
pbracher

Nested Class Summary
 
Nested classes/interfaces inherited from interface info.magnolia.cms.core.Content
Content.ContentFilter
 
Constructor Summary
InheritanceContentWrapper(Content node)
          Starts the inheritance.
InheritanceContentWrapper(Content wrappedContent, Content start)
          Used if in the wrap(Content) method.
 
Method Summary
protected  InheritanceContentWrapper findAnchor()
          Find the anchor for this node.
protected  InheritanceContentWrapper findNextAnchor()
          Find next anchor.
 Collection<Content> getChildren(Content.ContentFilter filter, String namePattern, Comparator<Content> orderCriteria)
           
 Content getContent(String name)
          Gets the Content node of the current node with the specified name.
protected  Content getContentSafely(InheritanceContentWrapper anchor, String path)
          This method returns null if no content has been found.
protected  Content getContentSafely(String name)
          This method returns null if no content has been found.
 NodeData getNodeData(String name)
          Returns a NodeData object.
 boolean hasContent(String name)
           
 boolean hasNodeData(String name)
          Delegates to NodeData.isExist().
protected  boolean isAnchor()
          True if this node is an anchor.
 boolean isInherited()
          True if this is not a sub node of the starting point.
protected  String resolveInnerPath()
          Returns the inner path of the this node up to the anchor.
protected  Content wrap(Content node)
          Wrap returned nodes.
 
Methods inherited from class info.magnolia.cms.util.ContentWrapper
addMixin, addVersion, addVersion, createContent, delete, deleteNodeData, getAllVersions, getAncestor, getAncestors, getBaseVersion, getChildByName, getHandle, getHierarchyManager, getIndex, getItemType, getJCRNode, getLevel, getLock, getMetaData, getMixinNodeTypes, getName, getNodeDataCollection, getNodeType, getNodeTypeName, getParent, getTemplate, getTitle, getUUID, getVersionedContent, getVersionedContent, getVersionHistory, getWorkspace, getWrappedContent, hasMetaData, hasMixin, holdsLock, isGranted, isLocked, isModified, isNodeData, isNodeType, lock, lock, newNodeDataInstance, orderBefore, refresh, removeMixin, removeVersionHistory, restore, restore, restore, restoreByLabel, save, setWrappedContent, toString, unlock, updateMetaData, wrap, wrapContentNodes, wrapNodeDatas
 
Methods inherited from class info.magnolia.cms.core.AbstractContent
createContent, createContent, createNodeData, createNodeData, createNodeData, createNodeData, createNodeData, delete, getBinaryNodeDatas, getChildren, getChildren, getChildren, getChildren, getChildren, getChildren, getNodeDataCollection, hasChildren, hasChildren, setNodeData, setNodeData, setNodeData, setNodeData, setNodeData, setNodeData, setNodeData, setNodeData, setNodeData, setNodeData
 
Methods inherited from class info.magnolia.cms.core.ContentHandler
clone, getAccessManager, setAccessManager
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface info.magnolia.cms.core.Content
getAccessManager
 

Constructor Detail

InheritanceContentWrapper

public InheritanceContentWrapper(Content wrappedContent,
                                 Content start)
Used if in the wrap(Content) method.


InheritanceContentWrapper

public InheritanceContentWrapper(Content node)
Starts the inheritance.

Method Detail

hasContent

public boolean hasContent(String name)
                   throws javax.jcr.RepositoryException
Specified by:
hasContent in interface Content
Overrides:
hasContent in class ContentWrapper
Throws:
javax.jcr.RepositoryException - if an error occurs

getContent

public Content getContent(String name)
                   throws javax.jcr.RepositoryException
Description copied from interface: Content
Gets the Content node of the current node with the specified name.

Specified by:
getContent in interface Content
Overrides:
getContent in class ContentWrapper
Parameters:
name - of the node acting as Content
Returns:
Content
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException - if an error occurs
AccessDeniedException - if the current session does not have sufficient access rights to complete the operation

getChildren

public Collection<Content> getChildren(Content.ContentFilter filter,
                                       String namePattern,
                                       Comparator<Content> orderCriteria)
Overrides:
getChildren in class ContentWrapper
namePattern - ignored if null.

resolveInnerPath

protected String resolveInnerPath()
                           throws javax.jcr.RepositoryException
Returns the inner path of the this node up to the anchor.

Throws:
javax.jcr.RepositoryException

getContentSafely

protected Content getContentSafely(String name)
                            throws javax.jcr.RepositoryException
This method returns null if no content has been found.

Throws:
javax.jcr.RepositoryException

getContentSafely

protected Content getContentSafely(InheritanceContentWrapper anchor,
                                   String path)
                            throws javax.jcr.RepositoryException
This method returns null if no content has been found.

Throws:
javax.jcr.RepositoryException

findAnchor

protected InheritanceContentWrapper findAnchor()
                                        throws javax.jcr.RepositoryException
Find the anchor for this node.

Throws:
javax.jcr.RepositoryException

findNextAnchor

protected InheritanceContentWrapper findNextAnchor()
                                            throws javax.jcr.RepositoryException
Find next anchor.

Throws:
javax.jcr.RepositoryException

isAnchor

protected boolean isAnchor()
True if this node is an anchor. By default true if this node is of type mgnl:content (page)


getNodeData

public NodeData getNodeData(String name)
Description copied from class: AbstractContent
Returns a NodeData object. If the node data does not exist (respectively if it has no value) an empty representation is returned whose NodeData.isExist() will return false. Delegates to AbstractContent.newNodeDataInstance(String, int, boolean) by setting the type to PropertyType.UNDEFINED. A subclass has to handle this by trying to determine the type if the node data exists. The reason for this is that implementations want to instantiate different node data classes per type

Specified by:
getNodeData in interface Content
Overrides:
getNodeData in class AbstractContent
Returns:
NodeData requested NodeData object

hasNodeData

public boolean hasNodeData(String name)
                    throws javax.jcr.RepositoryException
Description copied from class: AbstractContent
Delegates to NodeData.isExist().

Specified by:
hasNodeData in interface Content
Overrides:
hasNodeData in class AbstractContent
Throws:
javax.jcr.RepositoryException - if an error occurs

wrap

protected Content wrap(Content node)
Wrap returned nodes. Sets the inherited flag

Overrides:
wrap in class ContentWrapper

isInherited

public boolean isInherited()
True if this is not a sub node of the starting point.



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