org.apache.jackrabbit.core.nodetype
Class NodeTypeManagerImpl

java.lang.Object
  extended by org.apache.jackrabbit.spi.commons.nodetype.AbstractNodeTypeManager
      extended by org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl
All Implemented Interfaces:
NodeTypeManager, JackrabbitNodeTypeManager, NodeTypeRegistryListener

public class NodeTypeManagerImpl
extends AbstractNodeTypeManager
implements JackrabbitNodeTypeManager, NodeTypeRegistryListener

A NodeTypeManagerImpl implements a session dependant NodeTypeManager.


Field Summary
 
Fields inherited from interface org.apache.jackrabbit.api.JackrabbitNodeTypeManager
TEXT_X_JCR_CND, TEXT_XML
 
Constructor Summary
NodeTypeManagerImpl(SessionContext context)
          Creates a new NodeTypeManagerImpl instance.
 
Method Summary
 NodeTypeIterator getAllNodeTypes()
          
 NodeTypeIterator getMixinNodeTypes()
          
 NamePathResolver getNamePathResolver()
          Returns the NamePathResolver used to validate JCR names.
 NodeDefinitionImpl getNodeDefinition(QNodeDefinition def)
          Retrieve the NodeDefinition for the given QNodeDefinition.
 NodeTypeImpl getNodeType(Name name)
          Return the node type with the specified ntName.
 NodeType getNodeType(String nodeTypeName)
          
 NodeTypeRegistry getNodeTypeRegistry()
           
 NodeTypeIterator getPrimaryNodeTypes()
          
 PropertyDefinitionImpl getPropertyDefinition(QPropertyDefinition def)
          Retrieve the PropertyDefinition for the given QPropertyDefinition.
 NodeDefinitionImpl getRootNodeDefinition()
           
 boolean hasNodeType(String name)
          Checks whether a node type with the given name exists.
 void nodeTypeRegistered(Name ntName)
          Called when a node type has been registered.
 void nodeTypeReRegistered(Name ntName)
          Called when a node type has been re-registered.
 void nodeTypesUnregistered(Collection<Name> names)
          Called when a set of node types has been unregistered.
 NodeType[] registerNodeTypes(InputSource in)
          Registers the node types defined in the given XML stream.
 NodeType[] registerNodeTypes(InputStream in, String contentType)
          Registers the node types defined in the given input stream depending on the content type specified for the stream.
 NodeType[] registerNodeTypes(InputStream in, String contentType, boolean reregisterExisting)
          Registers the node types defined in the given input stream depending on the content type specified for the stream.
 NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] definitions, boolean allowUpdate)
          Registers or updates the specified Collection of NodeTypeDefinition objects.
 String toString()
          
 void unregisterNodeTypes(String[] names)
          Unregisters the specified set of node types.
 
Methods inherited from class org.apache.jackrabbit.spi.commons.nodetype.AbstractNodeTypeManager
createNodeDefinitionTemplate, createNodeTypeTemplate, createNodeTypeTemplate, createPropertyDefinitionTemplate, registerNodeType, unregisterNodeType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.jcr.nodetype.NodeTypeManager
createNodeDefinitionTemplate, createNodeTypeTemplate, createNodeTypeTemplate, createPropertyDefinitionTemplate, registerNodeType, unregisterNodeType
 

Constructor Detail

NodeTypeManagerImpl

public NodeTypeManagerImpl(SessionContext context)
Creates a new NodeTypeManagerImpl instance.

Parameters:
ntReg - node type registry
session - current session
store - the data store
Method Detail

getRootNodeDefinition

public NodeDefinitionImpl getRootNodeDefinition()
Returns:
the root node definition

getNodeDefinition

public NodeDefinitionImpl getNodeDefinition(QNodeDefinition def)
Description copied from class: AbstractNodeTypeManager
Retrieve the NodeDefinition for the given QNodeDefinition.

Specified by:
getNodeDefinition in class AbstractNodeTypeManager
Parameters:
def - the QNodeDefinition
Returns:
the node definition

getPropertyDefinition

public PropertyDefinitionImpl getPropertyDefinition(QPropertyDefinition def)
Description copied from class: AbstractNodeTypeManager
Retrieve the PropertyDefinition for the given QPropertyDefinition.

Specified by:
getPropertyDefinition in class AbstractNodeTypeManager
Parameters:
def - prop def
Returns:
the property definition

getNodeType

public NodeTypeImpl getNodeType(Name name)
                         throws NoSuchNodeTypeException
Description copied from class: AbstractNodeTypeManager
Return the node type with the specified ntName.

Specified by:
getNodeType in class AbstractNodeTypeManager
Parameters:
name - node type name
Returns:
node type
Throws:
NoSuchNodeTypeException - if the nodetype does not exit

getNamePathResolver

public NamePathResolver getNamePathResolver()
Description copied from class: AbstractNodeTypeManager
Returns the NamePathResolver used to validate JCR names.

Specified by:
getNamePathResolver in class AbstractNodeTypeManager
Returns:
the NamePathResolver used to convert JCR names/paths to internal onces and vice versa. The resolver may also be used to validate names passed to the various templates.
See Also:
AbstractNodeTypeManager.getNamePathResolver()

getNodeTypeRegistry

public NodeTypeRegistry getNodeTypeRegistry()
Returns:
the node type registry

registerNodeTypes

public NodeType[] registerNodeTypes(InputStream in,
                                    String contentType,
                                    boolean reregisterExisting)
                             throws IOException,
                                    RepositoryException
Registers the node types defined in the given input stream depending on the content type specified for the stream. This will also register any namespaces identified in the input stream if they have not already been registered.

Parameters:
in - node type XML stream
contentType - type of the input stream
reregisterExisting - flag indicating whether node types should be reregistered if they already exist
Returns:
registered node types
Throws:
IOException - if the input stream could not be read or parsed
RepositoryException - if the node types are invalid or another repository error occurs

nodeTypeRegistered

public void nodeTypeRegistered(Name ntName)
Called when a node type has been registered.

Specified by:
nodeTypeRegistered in interface NodeTypeRegistryListener
Parameters:
ntName - name of the node type that has been registered

nodeTypeReRegistered

public void nodeTypeReRegistered(Name ntName)
Called when a node type has been re-registered.

Specified by:
nodeTypeReRegistered in interface NodeTypeRegistryListener
Parameters:
ntName - name of the node type that has been registered

nodeTypesUnregistered

public void nodeTypesUnregistered(Collection<Name> names)
Called when a set of node types has been unregistered.

Specified by:
nodeTypesUnregistered in interface NodeTypeRegistryListener
Parameters:
names - names of the types that have been unregistered

getAllNodeTypes

public NodeTypeIterator getAllNodeTypes()
                                 throws RepositoryException

Specified by:
getAllNodeTypes in interface NodeTypeManager
Throws:
RepositoryException

getPrimaryNodeTypes

public NodeTypeIterator getPrimaryNodeTypes()
                                     throws RepositoryException

Specified by:
getPrimaryNodeTypes in interface NodeTypeManager
Throws:
RepositoryException

getMixinNodeTypes

public NodeTypeIterator getMixinNodeTypes()
                                   throws RepositoryException

Specified by:
getMixinNodeTypes in interface NodeTypeManager
Throws:
RepositoryException

getNodeType

public NodeType getNodeType(String nodeTypeName)
                     throws NoSuchNodeTypeException

Specified by:
getNodeType in interface NodeTypeManager
Throws:
NoSuchNodeTypeException

registerNodeTypes

public NodeType[] registerNodeTypes(InputSource in)
                             throws SAXException,
                                    RepositoryException
Registers the node types defined in the given XML stream. This is a trivial implementation that just invokes the existing NodeTypeReader and NodeTypeRegistry methods and heuristically creates the returned node type array. It will also register any namespaces defined in the input source that have not already been registered. Registers node types from the given node type XML stream.

Specified by:
registerNodeTypes in interface JackrabbitNodeTypeManager
Parameters:
in - node type XML stream
Returns:
registered node types
Throws:
SAXException - if the XML stream could not be read or parsed
RepositoryException - if the node types are invalid or another repository error occurs

registerNodeTypes

public NodeType[] registerNodeTypes(InputStream in,
                                    String contentType)
                             throws IOException,
                                    RepositoryException
Registers the node types defined in the given input stream depending on the content type specified for the stream. This will also register any namespaces identified in the input stream if they have not already been registered. Registers node types from the given input stream of the given type.

Specified by:
registerNodeTypes in interface JackrabbitNodeTypeManager
Parameters:
in - node type stream
contentType - type of the input stream
Returns:
registered node types
Throws:
IOException - if the input stream could not be read or parsed
RepositoryException - if the node types are invalid or another repository error occurs

hasNodeType

public boolean hasNodeType(String name)
                    throws RepositoryException
Checks whether a node type with the given name exists.

Specified by:
hasNodeType in interface NodeTypeManager
Specified by:
hasNodeType in interface JackrabbitNodeTypeManager
Parameters:
name - node type name
Returns:
true if the named node type exists, false otherwise
Throws:
RepositoryException - if the name format is invalid

registerNodeTypes

public NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] definitions,
                                          boolean allowUpdate)
                                   throws InvalidNodeTypeDefinitionException,
                                          NodeTypeExistsException,
                                          UnsupportedRepositoryOperationException,
                                          RepositoryException
Registers or updates the specified Collection of NodeTypeDefinition objects. This method is used to register or update a set of node types with mutual dependencies. Returns an iterator over the resulting NodeType objects.

The effect of the method is "all or nothing"; if an error occurs, no node types are registered or updated.

Throws an InvalidNodeTypeDefinitionException if a NodeTypeDefinition within the Collection is invalid or if the Collection contains an object of a type other than NodeTypeDefinition.

Throws a NodeTypeExistsException if allowUpdate is false and a NodeTypeDefinition within the Collection specifies a node type name that is already registered.

Throws an UnsupportedRepositoryOperationException if this implementation does not support node type registration.

Specified by:
registerNodeTypes in interface NodeTypeManager
Parameters:
definitions - a collection of NodeTypeDefinitions
allowUpdate - a boolean
Returns:
the registered node types.
Throws:
InvalidNodeTypeDefinitionException - if a NodeTypeDefinition within the Collection is invalid or if the Collection contains an object of a type other than NodeTypeDefinition.
NodeTypeExistsException - if allowUpdate is false and a NodeTypeDefinition within the Collection specifies a node type name that is already registered.
UnsupportedRepositoryOperationException - if this implementation does not support node type registration.
RepositoryException - if another error occurs.
Since:
JCR 2.0

unregisterNodeTypes

public void unregisterNodeTypes(String[] names)
                         throws UnsupportedRepositoryOperationException,
                                NoSuchNodeTypeException,
                                RepositoryException
Unregisters the specified set of node types. Used to unregister a set of node types with mutual dependencies.

Throws a NoSuchNodeTypeException if one of the names listed is not a registered node type.

Throws an UnsupportedRepositoryOperationException if this implementation does not support node type registration.

Specified by:
unregisterNodeTypes in interface NodeTypeManager
Parameters:
names - a String array
Throws:
UnsupportedRepositoryOperationException - if this implementation does not support node type registration.
NoSuchNodeTypeException - if one of the names listed is not a registered node type.
RepositoryException - if another error occurs.
Since:
JCR 2.0

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.