info.magnolia.cms.util
Class ExtendingContentWrapper

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.ExtendingContentWrapper
All Implemented Interfaces:
Content, java.lang.Cloneable

public class ExtendingContentWrapper
extends ContentWrapper

This wrapper allows extending other nodes (mainly useful to extend configurations). A content node can define a nodeData with the name 'extends'. Its value is either an absolute or relative path. The merge is then performed as follows:

The mechanism supports multiple inheritances as such:

Version:
$Id$
Author:
pbaerfuss
See Also:
a class supporting content inheritance.

Nested Class Summary
 
Nested classes/interfaces inherited from interface info.magnolia.cms.core.Content
Content.ContentFilter
 
Field Summary
protected static java.lang.String EXTENDING_NODE_DATA
           
protected static java.lang.String EXTENDING_NODE_DATA_OVERRIDE
           
 
Fields inherited from class info.magnolia.cms.core.ContentHandler
hierarchyManager
 
Constructor Summary
  ExtendingContentWrapper(Content wrappedContent)
           
protected ExtendingContentWrapper(Content wrappedContent, Content extendedContent)
          Does not support the extends nodedata but chains the two nodes directly.
 
Method Summary
 java.util.Collection<Content> getChildren(Content.ContentFilter filter, java.lang.String namePattern, java.util.Comparator<Content> orderCriteria)
           
 Content getContent(java.lang.String name)
          Gets the Content node of the current node with the specified name.
 NodeData getNodeData(java.lang.String name)
          Returns a NodeData object.
 java.util.Collection<NodeData> getNodeDataCollection()
          Gets all properties bind in NodeData object excluding JCR system properties.
 Content getWrappedContent()
           
 boolean hasContent(java.lang.String name)
           
 boolean hasNodeData(java.lang.String name)
          Delegates to NodeData.isExist().
 boolean isExtending()
           
protected  Content wrap(Content node)
          Override if a wrapper wants to wrap returned content objects.
 
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, 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, hasChildren, hasChildren, setNodeData, setNodeData, setNodeData, setNodeData, setNodeData, setNodeData, setNodeData, setNodeData, setNodeData, setNodeData
 
Methods inherited from class info.magnolia.cms.core.ContentHandler
clone, getAccessManager, setAccessManager, setHierarchyManager
 
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
 

Field Detail

EXTENDING_NODE_DATA

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

EXTENDING_NODE_DATA_OVERRIDE

protected static final java.lang.String EXTENDING_NODE_DATA_OVERRIDE
See Also:
Constant Field Values
Constructor Detail

ExtendingContentWrapper

public ExtendingContentWrapper(Content wrappedContent)

ExtendingContentWrapper

protected ExtendingContentWrapper(Content wrappedContent,
                                  Content extendedContent)
Does not support the extends nodedata but chains the two nodes directly. Each node is wrapped internally to ensure that each of them support the extends nodedata for themselves.

Method Detail

isExtending

public boolean isExtending()

getWrappedContent

public Content getWrappedContent()
Overrides:
getWrappedContent in class ContentWrapper

hasContent

public boolean hasContent(java.lang.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(java.lang.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 java.util.Collection<Content> getChildren(Content.ContentFilter filter,
                                                 java.lang.String namePattern,
                                                 java.util.Comparator<Content> orderCriteria)
Overrides:
getChildren in class ContentWrapper
namePattern - ignored if null.

getNodeData

public NodeData getNodeData(java.lang.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(java.lang.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

getNodeDataCollection

public java.util.Collection<NodeData> getNodeDataCollection()
Description copied from interface: Content
Gets all properties bind in NodeData object excluding JCR system properties.

Specified by:
getNodeDataCollection in interface Content
Overrides:
getNodeDataCollection in class AbstractContent

wrap

protected Content wrap(Content node)
Description copied from class: ContentWrapper
Override if a wrapper wants to wrap returned content objects. This method is called by getContent(), getParent(), ... The default implementation does nothing.

Overrides:
wrap in class ContentWrapper


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