org.apache.jackrabbit.core.nodetype
Class NodeTypeManagerImpl

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

public class NodeTypeManagerImpl
extends Object
implements JackrabbitNodeTypeManager, Dumpable, 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(NodeTypeRegistry ntReg, SessionImpl session, DataStore store)
          Creates a new NodeTypeManagerImpl instance.
 
Method Summary
 NodeDefinitionTemplate createNodeDefinitionTemplate()
          Returns an empty NodeDefinitionTemplate which can then be used to create a child node definition and attached to a NodeTypeTemplate.
 NodeTypeTemplate createNodeTypeTemplate()
          Returns an empty NodeTypeTemplate which can then be used to define a node type and passed to NodeTypeManager.registerNodeType.
 NodeTypeTemplate createNodeTypeTemplate(NodeTypeDefinition ntd)
          Returns a NodeTypeTemplate holding the specified node type definition.
 PropertyDefinitionTemplate createPropertyDefinitionTemplate()
          Returns an empty PropertyDefinitionTemplate which can then be used to create a property definition and attached to a NodeTypeTemplate.
 void dump(PrintStream ps)
          Dumps the state of this instance in a human readable format for diagnostic purposes.
 NodeTypeIterator getAllNodeTypes()
          
 NodeTypeIterator getMixinNodeTypes()
          
 NodeDefinitionImpl getNodeDefinition(NodeDefId id)
           
 NodeTypeImpl getNodeType(Name name)
           
 NodeType getNodeType(String nodeTypeName)
          
 NodeTypeRegistry getNodeTypeRegistry()
           
 NodeTypeIterator getPrimaryNodeTypes()
          
 PropertyDefinitionImpl getPropertyDefinition(PropDefId id)
           
 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 nodeTypeUnregistered(Name ntName)
          Called when a node type has been deregistered.
 NodeType registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate)
          Registers a new node type or updates an existing node type using the specified definition and returns the resulting NodeType object.
 NodeTypeIterator registerNodeTypes(Collection definitions, boolean allowUpdate)
          Registers or updates the specified Collection of NodeTypeDefinition objects.
 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.
 void unregisterNodeType(String name)
          Unregisters the specified node type.
 void unregisterNodeTypes(String[] names)
          Unregisters the specified set of node types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeTypeManagerImpl

public NodeTypeManagerImpl(NodeTypeRegistry ntReg,
                           SessionImpl session,
                           DataStore store)
Creates a new NodeTypeManagerImpl instance.

Parameters:
ntReg - node type registry
session - current session
Method Detail

getRootNodeDefinition

public NodeDefinitionImpl getRootNodeDefinition()
Returns:
the root node definition

getNodeDefinition

public NodeDefinitionImpl getNodeDefinition(NodeDefId id)
Parameters:
id -
Returns:
the node definition

getPropertyDefinition

public PropertyDefinitionImpl getPropertyDefinition(PropDefId id)
Parameters:
id -
Returns:
the property definition

getNodeType

public NodeTypeImpl getNodeType(Name name)
                         throws NoSuchNodeTypeException
Parameters:
name -
Returns:
Throws:
NoSuchNodeTypeException

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

nodeTypeUnregistered

public void nodeTypeUnregistered(Name ntName)
Called when a node type has been deregistered.

Specified by:
nodeTypeUnregistered in interface NodeTypeRegistryListener
Parameters:
ntName - name of the node type that has 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 JackrabbitNodeTypeManager
Parameters:
name - node type name
Returns:
true if the named node type exists, false otherwise
Throws:
RepositoryException - if the name format is invalid

createNodeTypeTemplate

public NodeTypeTemplate createNodeTypeTemplate()
                                        throws UnsupportedRepositoryOperationException,
                                               RepositoryException
Returns an empty NodeTypeTemplate which can then be used to define a node type and passed to NodeTypeManager.registerNodeType.

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

Returns:
A NodeTypeTemplate.
Throws:
UnsupportedRepositoryOperationException - if this implementation does not support node type registration.
RepositoryException - if another error occurs.
Since:
JCR 2.0

createNodeTypeTemplate

public NodeTypeTemplate createNodeTypeTemplate(NodeTypeDefinition ntd)
                                        throws UnsupportedRepositoryOperationException,
                                               RepositoryException
Returns a NodeTypeTemplate holding the specified node type definition. This template can then be altered and passed to NodeTypeManager.registerNodeType.

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

Parameters:
ntd - a NodeTypeDefinition.
Returns:
A NodeTypeTemplate.
Throws:
UnsupportedRepositoryOperationException - if this implementation does not support node type registration.
RepositoryException - if another error occurs.
Since:
JCR 2.0

createNodeDefinitionTemplate

public NodeDefinitionTemplate createNodeDefinitionTemplate()
                                                    throws UnsupportedRepositoryOperationException,
                                                           RepositoryException
Returns an empty NodeDefinitionTemplate which can then be used to create a child node definition and attached to a NodeTypeTemplate.

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

Returns:
A NodeDefinitionTemplate.
Throws:
UnsupportedRepositoryOperationException - if this implementation does not support node type registration.
RepositoryException - if another error occurs.
Since:
JCR 2.0

createPropertyDefinitionTemplate

public PropertyDefinitionTemplate createPropertyDefinitionTemplate()
                                                            throws UnsupportedRepositoryOperationException,
                                                                   RepositoryException
Returns an empty PropertyDefinitionTemplate which can then be used to create a property definition and attached to a NodeTypeTemplate.

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

Returns:
A PropertyDefinitionTemplate.
Throws:
UnsupportedRepositoryOperationException - if this implementation does not support node type registration.
RepositoryException - if another error occurs.
Since:
JCR 2.0

registerNodeType

public NodeType registerNodeType(NodeTypeDefinition ntd,
                                 boolean allowUpdate)
                          throws InvalidNodeTypeDefinitionException,
                                 NodeTypeExistsException,
                                 UnsupportedRepositoryOperationException,
                                 RepositoryException
Registers a new node type or updates an existing node type using the specified definition and returns the resulting NodeType object.

Typically, the object passed to this method will be a NodeTypeTemplate (a subclass of NodeTypeDefinition) acquired from NodeTypeManager.createNodeTypeTemplate and then filled-in with definition information.

Throws an InvalidNodeTypeDefinitionException if the NodeTypeDefinition is invalid.

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

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

Parameters:
ntd - an NodeTypeDefinition.
allowUpdate - a boolean
Returns:
the registered node type
Throws:
InvalidNodeTypeDefinitionException - if the NodeTypeDefinition is invalid.
NodeTypeExistsException - if allowUpdate is false and the NodeTypeDefinition 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

registerNodeTypes

public NodeTypeIterator registerNodeTypes(Collection 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.

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

unregisterNodeType

public void unregisterNodeType(String name)
                        throws UnsupportedRepositoryOperationException,
                               NoSuchNodeTypeException,
                               RepositoryException
Unregisters the specified node type.

Throws a NoSuchNodeTypeException if no registered node type exists with the specified name.

Parameters:
name - a String.
Throws:
UnsupportedRepositoryOperationException - if this implementation does not support node type registration.
NoSuchNodeTypeException - if no registered node type exists with the specified name.
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.

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

dump

public void dump(PrintStream ps)
Dumps the state of this instance in a human readable format for diagnostic purposes.

Specified by:
dump in interface Dumpable
Parameters:
ps - stream to dump state to


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