info.magnolia.cms.core
Class AbstractContent

java.lang.Object
  extended by info.magnolia.cms.core.ContentHandler
      extended by info.magnolia.cms.core.AbstractContent
All Implemented Interfaces:
Content, java.lang.Cloneable
Direct Known Subclasses:
ContentWrapper, DefaultContent

public abstract class AbstractContent
extends ContentHandler
implements Content

A base class by implementing some default behavior. A subclass must carefully implement newNodeDataInstance(String, int, boolean), getChildren(info.magnolia.cms.core.Content.ContentFilter, String, java.util.Comparator) and Content.getNodeDataCollection(String).

Version:
$Id$
Author:
pbaerfuss

Nested Class Summary
 
Nested classes/interfaces inherited from interface info.magnolia.cms.core.Content
Content.ContentFilter
 
Field Summary
 
Fields inherited from class info.magnolia.cms.core.ContentHandler
hierarchyManager
 
Constructor Summary
AbstractContent()
           
 
Method Summary
 Content createContent(java.lang.String name)
          Creates a Content node under the current node with the specified name.
 Content createContent(java.lang.String name, ItemType contentType)
          Creates a Content node under the current node with the specified name.
 NodeData createNodeData(java.lang.String name)
          Creates a node data of type STRING with an empty String as default value.
 NodeData createNodeData(java.lang.String name, int type)
          Deprecated.  
 NodeData createNodeData(java.lang.String name, java.lang.Object valueObj)
          Deprecated.  
 NodeData createNodeData(java.lang.String name, javax.jcr.Value value)
          Creates a node data setting the value.
 NodeData createNodeData(java.lang.String name, javax.jcr.Value[] value)
          Deprecated.  
 void delete(java.lang.String path)
          Remove specified path.
 void deleteNodeData(java.lang.String name)
          Delete NodeData with the specified name.
protected  java.util.Collection<NodeData> getBinaryNodeDatas(java.lang.String namePattern)
           
 Content getChildByName(java.lang.String namePattern)
          Deprecated.  
 java.util.Collection<Content> getChildren()
          Gets a Collection containing all child nodes of the same NodeType as "this" object.
 java.util.Collection<Content> getChildren(Content.ContentFilter filter)
          Get a collection containing child nodes which satisfies the given filter.
 java.util.Collection<Content> getChildren(Content.ContentFilter filter, java.util.Comparator<Content> orderCriteria)
          Get a collection containing child nodes which satisfies the given filter.
abstract  java.util.Collection<Content> getChildren(Content.ContentFilter filter, java.lang.String namePattern, java.util.Comparator<Content> orderCriteria)
           
 java.util.Collection<Content> getChildren(ItemType itemType)
          Get collection of specified content type.
 java.util.Collection<Content> getChildren(java.lang.String contentType)
          Get collection of specified content type and its subtypes.
 java.util.Collection<Content> getChildren(java.lang.String contentType, java.lang.String namePattern)
          Get collection of specified content type.
 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.
 java.lang.String getTemplate()
          Returns the template name which is assigned to this content.
 java.lang.String getTitle()
           
 javax.jcr.Workspace getWorkspace()
          get workspace to which this node attached to.
 boolean hasChildren()
           
 boolean hasChildren(java.lang.String contentType)
           
 boolean hasNodeData(java.lang.String name)
          Delegates to NodeData.isExist().
 boolean isGranted(long permissions)
          checks for the allowed access rights.
 boolean isNodeData(java.lang.String path)
          checks if the requested resource is an NodeData (Property).
abstract  NodeData newNodeDataInstance(java.lang.String name, int type, boolean createIfNotExisting)
          As defined in Content.getNodeData(String) this method always returns a node data object.
 NodeData setNodeData(java.lang.String name, boolean value)
          Sets the node data.
 NodeData setNodeData(java.lang.String name, java.util.Calendar value)
          Sets the node data.
 NodeData setNodeData(java.lang.String name, Content value)
          Sets the node data.
 NodeData setNodeData(java.lang.String name, double value)
          Sets the node data.
 NodeData setNodeData(java.lang.String name, java.io.InputStream value)
          Sets the node data.
 NodeData setNodeData(java.lang.String name, long value)
          Sets the node data.
 NodeData setNodeData(java.lang.String name, java.lang.Object value)
          Uses the NodeDataUtil to create and set the node data based on the object type.
 NodeData setNodeData(java.lang.String name, java.lang.String value)
          Sets the node data.
 NodeData setNodeData(java.lang.String name, javax.jcr.Value value)
          Sets the node data.
 NodeData setNodeData(java.lang.String name, javax.jcr.Value[] value)
          Sets the node data.
 java.lang.String toString()
           
 void updateMetaData()
          You could call this method anytime to update working page properties - Modification date & Author ID.
 
Methods inherited from class info.magnolia.cms.core.ContentHandler
clone, getAccessManager, getHierarchyManager, 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
addMixin, addVersion, addVersion, createContent, delete, getAccessManager, getAllVersions, getAncestor, getAncestors, getBaseVersion, getContent, getHandle, getHierarchyManager, getIndex, getItemType, getJCRNode, getLevel, getLock, getMetaData, getMixinNodeTypes, getName, getNodeDataCollection, getNodeType, getNodeTypeName, getParent, getUUID, getVersionedContent, getVersionedContent, getVersionHistory, hasContent, hasMetaData, hasMixin, holdsLock, isLocked, isModified, isNodeType, lock, lock, orderBefore, refresh, removeMixin, removeVersionHistory, restore, restore, restore, restoreByLabel, save, unlock
 

Constructor Detail

AbstractContent

public AbstractContent()
Method Detail

createContent

public Content createContent(java.lang.String name)
                      throws javax.jcr.PathNotFoundException,
                             javax.jcr.RepositoryException,
                             AccessDeniedException
Description copied from interface: Content
Creates a Content node under the current node with the specified name. The default node type ItemType.CONTENT will be use as the contents primary type.

Specified by:
createContent in interface Content
Parameters:
name - of the node to be created as Content
Returns:
newly created 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

createContent

public Content createContent(java.lang.String name,
                             ItemType contentType)
                      throws javax.jcr.PathNotFoundException,
                             javax.jcr.RepositoryException,
                             AccessDeniedException
Description copied from interface: Content
Creates a Content node under the current node with the specified name.

Specified by:
createContent in interface Content
Parameters:
name - of the node to be created as Content
contentType - ItemType
Returns:
newly created 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

createNodeData

public NodeData createNodeData(java.lang.String name)
                        throws javax.jcr.PathNotFoundException,
                               javax.jcr.RepositoryException,
                               AccessDeniedException
Description copied from interface: Content
Creates a node data of type STRING with an empty String as default value.

Specified by:
createNodeData in interface Content
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

createNodeData

public NodeData createNodeData(java.lang.String name,
                               javax.jcr.Value value)
                        throws javax.jcr.PathNotFoundException,
                               javax.jcr.RepositoryException,
                               AccessDeniedException
Description copied from interface: Content
Creates a node data setting the value.

Specified by:
createNodeData in interface Content
Throws:
AccessDeniedException - if the current session does not have sufficient access rights to complete the operation
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException

createNodeData

@Deprecated
public NodeData createNodeData(java.lang.String name,
                                          javax.jcr.Value[] value)
                        throws javax.jcr.PathNotFoundException,
                               javax.jcr.RepositoryException,
                               AccessDeniedException
Deprecated. 

Description copied from interface: Content
Create a multi value node data.

Specified by:
createNodeData in interface Content
Throws:
AccessDeniedException - if the current session does not have sufficient access rights to complete the operation
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException

createNodeData

@Deprecated
public NodeData createNodeData(java.lang.String name,
                                          int type)
                        throws javax.jcr.PathNotFoundException,
                               javax.jcr.RepositoryException,
                               AccessDeniedException
Deprecated. 

Description copied from interface: Content
Creates a node data of type with an default value set. If the no default value can be set (for BINARY, REFERENCE type) the returned node data will be empty and per definition not yet exist.

Specified by:
createNodeData in interface Content
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

createNodeData

@Deprecated
public NodeData createNodeData(java.lang.String name,
                                          java.lang.Object valueObj)
                        throws javax.jcr.RepositoryException
Deprecated. 

Description copied from interface: Content
Creates a property and set its value immediately, according to the type of the passed instance, hiding the complexity of using JCR's ValueFactory and providing a sensible default behavior.

Specified by:
createNodeData in interface Content
Throws:
javax.jcr.RepositoryException

getNodeData

public NodeData getNodeData(java.lang.String name)
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 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
Returns:
NodeData requested NodeData object

newNodeDataInstance

public abstract NodeData newNodeDataInstance(java.lang.String name,
                                             int type,
                                             boolean createIfNotExisting)
                                      throws AccessDeniedException,
                                             javax.jcr.RepositoryException
As defined in Content.getNodeData(String) this method always returns a node data object. If the type is PropertyType.UNDEFINED the implementation should check if the node data exists and determine the type to use.

Parameters:
createIfNotExisting - if false an empty non-mutable node data will be returned if the node data doesn't exist otherwise a mutable nodedata object is returned (depending on the type)
Throws:
AccessDeniedException
javax.jcr.RepositoryException

hasNodeData

public boolean hasNodeData(java.lang.String name)
                    throws javax.jcr.RepositoryException
Delegates to NodeData.isExist().

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

setNodeData

public NodeData setNodeData(java.lang.String name,
                            javax.jcr.Value value)
                     throws javax.jcr.PathNotFoundException,
                            javax.jcr.RepositoryException,
                            AccessDeniedException
Description copied from interface: Content
Sets the node data. If the node data does not yet exist the node data is created. Setting null is not allowed

Specified by:
setNodeData in interface Content
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

setNodeData

public NodeData setNodeData(java.lang.String name,
                            javax.jcr.Value[] value)
                     throws javax.jcr.PathNotFoundException,
                            javax.jcr.RepositoryException,
                            AccessDeniedException
Description copied from interface: Content
Sets the node data. If the node data does not yet exist the node data is created. Setting null is not allowed.

Specified by:
setNodeData in interface Content
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

setNodeData

public NodeData setNodeData(java.lang.String name,
                            boolean value)
                     throws javax.jcr.PathNotFoundException,
                            javax.jcr.RepositoryException,
                            AccessDeniedException
Description copied from interface: Content
Sets the node data. If the node data does not yet exist the node data is created. Setting null will remove the node data.

Specified by:
setNodeData in interface Content
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

setNodeData

public NodeData setNodeData(java.lang.String name,
                            long value)
                     throws javax.jcr.PathNotFoundException,
                            javax.jcr.RepositoryException,
                            AccessDeniedException
Description copied from interface: Content
Sets the node data. If the node data does not yet exist the node data is created. Setting null is not allowed.

Specified by:
setNodeData in interface Content
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

setNodeData

public NodeData setNodeData(java.lang.String name,
                            double value)
                     throws javax.jcr.PathNotFoundException,
                            javax.jcr.RepositoryException,
                            AccessDeniedException
Description copied from interface: Content
Sets the node data. If the node data does not yet exist the node data is created. Setting null will remove the node data.

Specified by:
setNodeData in interface Content
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

setNodeData

public NodeData setNodeData(java.lang.String name,
                            java.lang.String value)
                     throws javax.jcr.PathNotFoundException,
                            javax.jcr.RepositoryException,
                            AccessDeniedException
Description copied from interface: Content
Sets the node data. If the node data does not yet exist the node data is created. Setting null is not allowed.

Specified by:
setNodeData in interface Content
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

setNodeData

public NodeData setNodeData(java.lang.String name,
                            java.io.InputStream value)
                     throws javax.jcr.PathNotFoundException,
                            javax.jcr.RepositoryException,
                            AccessDeniedException
Description copied from interface: Content
Sets the node data. If the node data does not yet exist the node data is created. Setting null is not allowed.

Specified by:
setNodeData in interface Content
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

setNodeData

public NodeData setNodeData(java.lang.String name,
                            java.util.Calendar value)
                     throws javax.jcr.PathNotFoundException,
                            javax.jcr.RepositoryException,
                            AccessDeniedException
Description copied from interface: Content
Sets the node data. If the node data does not yet exist the node data is created. Setting null will remove the node data.

Specified by:
setNodeData in interface Content
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

setNodeData

public NodeData setNodeData(java.lang.String name,
                            Content value)
                     throws javax.jcr.PathNotFoundException,
                            javax.jcr.RepositoryException,
                            AccessDeniedException
Description copied from interface: Content
Sets the node data. If the node data does not yet exist the node data is created. Setting null will remove the node data.

Specified by:
setNodeData in interface Content
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

setNodeData

public NodeData setNodeData(java.lang.String name,
                            java.lang.Object value)
                     throws javax.jcr.PathNotFoundException,
                            javax.jcr.RepositoryException,
                            AccessDeniedException
Uses the NodeDataUtil to create and set the node data based on the object type.

Specified by:
setNodeData in interface Content
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

deleteNodeData

public void deleteNodeData(java.lang.String name)
                    throws javax.jcr.PathNotFoundException,
                           javax.jcr.RepositoryException
Description copied from interface: Content
Delete NodeData with the specified name.

Specified by:
deleteNodeData in interface Content
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException - if an error occurs

getChildren

public java.util.Collection<Content> getChildren()
Gets a Collection containing all child nodes of the same NodeType as "this" object. Delegates to getChildren(ItemType) passing the current node's type.

Specified by:
getChildren in interface Content
Returns:
Collection of content objects

getChildren

public java.util.Collection<Content> getChildren(Content.ContentFilter filter)
Get a collection containing child nodes which satisfies the given filter. Delegates to {@link #getChildren(info.magnolia.cms.core.Content.ContentFilter, java.util.Comparator).

Specified by:
getChildren in interface Content
Returns:
Collection of content objects or empty collection when no children are found.

getChildren

public java.util.Collection<Content> getChildren(ItemType itemType)
Get collection of specified content type. Delegates to {@link #getChildren(info.magnolia.cms.core.Content.ContentFilter, java.util.Comparator).

Specified by:
getChildren in interface Content
Parameters:
itemType - ItemType
Returns:
Collection of content nodes

getChildren

public java.util.Collection<Content> getChildren(java.lang.String contentType)
Get collection of specified content type and its subtypes. Delegates to {@link #getChildren(info.magnolia.cms.core.Content.ContentFilter, java.util.Comparator).

Specified by:
getChildren in interface Content
Parameters:
contentType - JCR node type as configured
Returns:
Collection of content nodes

getChildren

public java.util.Collection<Content> getChildren(java.lang.String contentType,
                                                 java.lang.String namePattern)
Get collection of specified content type. Delegates to getChildren(info.magnolia.cms.core.Content.ContentFilter, String, java.util.Comparator).

Specified by:
getChildren in interface Content
Parameters:
contentType - JCR node type as configured
Returns:
Collection of content nodes

getChildren

public java.util.Collection<Content> getChildren(Content.ContentFilter filter,
                                                 java.util.Comparator<Content> orderCriteria)
Get a collection containing child nodes which satisfies the given filter. The returned collection is ordered according to the passed in criteria. Delegates to getChildren(info.magnolia.cms.core.Content.ContentFilter, String, java.util.Comparator).

Specified by:
getChildren in interface Content
Parameters:
filter - filter for the child nodes
orderCriteria - ordering for the selected child nodes; if null than no particular order of the child nodes
Returns:
Collection of content objects or empty collection when no children are found.

getChildren

public abstract java.util.Collection<Content> getChildren(Content.ContentFilter filter,
                                                          java.lang.String namePattern,
                                                          java.util.Comparator<Content> orderCriteria)
Parameters:
namePattern - ignored if null.

getChildByName

@Deprecated
public Content getChildByName(java.lang.String namePattern)
Deprecated. 

Description copied from interface: Content
Returns the first child with the given name, any node type.

Specified by:
getChildByName in interface Content
Parameters:
namePattern - child node name
Returns:
first found node with the given name or null if not found

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

getBinaryNodeDatas

protected java.util.Collection<NodeData> getBinaryNodeDatas(java.lang.String namePattern)
                                                     throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

hasChildren

public boolean hasChildren()
Specified by:
hasChildren in interface Content
Returns:
Boolean, if sub node(s) exists

hasChildren

public boolean hasChildren(java.lang.String contentType)
Specified by:
hasChildren in interface Content
Parameters:
contentType - JCR node type as configured
Returns:
Boolean, if sub collectionType exists

delete

public void delete(java.lang.String path)
            throws javax.jcr.RepositoryException
Description copied from interface: Content
Remove specified path.

Specified by:
delete in interface Content
Throws:
javax.jcr.RepositoryException - if an error occurs

isNodeData

public boolean isNodeData(java.lang.String path)
                   throws AccessDeniedException,
                          javax.jcr.RepositoryException
Description copied from interface: Content
checks if the requested resource is an NodeData (Property).

Specified by:
isNodeData in interface Content
Parameters:
path - of the requested NodeData
Returns:
boolean true is the requested content is an NodeData
Throws:
AccessDeniedException
javax.jcr.RepositoryException - if an error occurs

getTemplate

public java.lang.String getTemplate()
Description copied from interface: Content
Returns the template name which is assigned to this content.

Specified by:
getTemplate in interface Content

getTitle

public java.lang.String getTitle()
Specified by:
getTitle in interface Content
Returns:
String, title

updateMetaData

public void updateMetaData()
                    throws javax.jcr.RepositoryException,
                           AccessDeniedException
Description copied from interface: Content
You could call this method anytime to update working page properties - Modification date & Author ID.

Specified by:
updateMetaData in interface Content
Throws:
AccessDeniedException - if the current session does not have sufficient access rights to complete the operation
javax.jcr.RepositoryException - if an error occurs

isGranted

public boolean isGranted(long permissions)
Description copied from interface: Content
checks for the allowed access rights.

Specified by:
isGranted in interface Content
Parameters:
permissions - as defined in javax.jcr.Permission
Returns:
true is the current user has specified access on this node.

getWorkspace

public javax.jcr.Workspace getWorkspace()
                                 throws javax.jcr.RepositoryException
Description copied from interface: Content
get workspace to which this node attached to.

Specified by:
getWorkspace in interface Content
Throws:
javax.jcr.RepositoryException - if unable to get this node session

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


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