Class NodeTypeManagerImpl
- java.lang.Object
-
- org.apache.jackrabbit.spi.commons.nodetype.AbstractNodeTypeManager
-
- org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl
-
- All Implemented Interfaces:
NodeTypeManager
,JackrabbitNodeTypeManager
,NodeTypeRegistryListener
public class NodeTypeManagerImpl extends AbstractNodeTypeManager implements JackrabbitNodeTypeManager, NodeTypeRegistryListener
ANodeTypeManagerImpl
implements a session dependant NodeTypeManager.
-
-
Field Summary
-
Fields inherited from interface org.apache.jackrabbit.api.JackrabbitNodeTypeManager
TEXT_X_JCR_CND, TEXT_XML
-
-
Constructor Summary
Constructors Constructor Description NodeTypeManagerImpl(SessionContext context)
Creates a newNodeTypeManagerImpl
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
Disposes this node type manager.NodeTypeIterator
getAllNodeTypes()
NodeTypeIterator
getMixinNodeTypes()
NamePathResolver
getNamePathResolver()
Returns the NamePathResolver used to validate JCR names.NodeDefinitionImpl
getNodeDefinition(QNodeDefinition def)
Retrieve theNodeDefinition
for the givenQNodeDefinition
.NodeType
getNodeType(String nodeTypeName)
NodeTypeImpl
getNodeType(Name name)
Return the node type with the specifiedntName
.NodeTypeRegistry
getNodeTypeRegistry()
NodeTypeIterator
getPrimaryNodeTypes()
PropertyDefinitionImpl
getPropertyDefinition(QPropertyDefinition def)
Retrieve thePropertyDefinition
for the givenQPropertyDefinition
.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(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 specifiedCollection
ofNodeTypeDefinition
objects.NodeType[]
registerNodeTypes(InputSource in)
Registers the node types defined in the given XML stream.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 newNodeTypeManagerImpl
instance.- Parameters:
context
- the session context
-
-
Method Detail
-
dispose
public void dispose()
Disposes this node type manager.
-
getRootNodeDefinition
public NodeDefinitionImpl getRootNodeDefinition()
- Returns:
- the root node definition
-
getNodeDefinition
public NodeDefinitionImpl getNodeDefinition(QNodeDefinition def)
Description copied from class:AbstractNodeTypeManager
Retrieve theNodeDefinition
for the givenQNodeDefinition
.- Specified by:
getNodeDefinition
in classAbstractNodeTypeManager
- Parameters:
def
- the QNodeDefinition- Returns:
- the node definition
-
getPropertyDefinition
public PropertyDefinitionImpl getPropertyDefinition(QPropertyDefinition def)
Description copied from class:AbstractNodeTypeManager
Retrieve thePropertyDefinition
for the givenQPropertyDefinition
.- Specified by:
getPropertyDefinition
in classAbstractNodeTypeManager
- 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 specifiedntName
.- Specified by:
getNodeType
in classAbstractNodeTypeManager
- 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 classAbstractNodeTypeManager
- 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 streamcontentType
- type of the input streamreregisterExisting
- 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 parsedRepositoryException
- 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 interfaceNodeTypeRegistryListener
- 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 interfaceNodeTypeRegistryListener
- 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 interfaceNodeTypeRegistryListener
- Parameters:
names
- names of the types that have been unregistered
-
getAllNodeTypes
public NodeTypeIterator getAllNodeTypes() throws RepositoryException
- Specified by:
getAllNodeTypes
in interfaceNodeTypeManager
- Throws:
RepositoryException
-
getPrimaryNodeTypes
public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException
- Specified by:
getPrimaryNodeTypes
in interfaceNodeTypeManager
- Throws:
RepositoryException
-
getMixinNodeTypes
public NodeTypeIterator getMixinNodeTypes() throws RepositoryException
- Specified by:
getMixinNodeTypes
in interfaceNodeTypeManager
- Throws:
RepositoryException
-
getNodeType
public NodeType getNodeType(String nodeTypeName) throws NoSuchNodeTypeException
- Specified by:
getNodeType
in interfaceNodeTypeManager
- 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 existingNodeTypeReader
andNodeTypeRegistry
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.- Specified by:
registerNodeTypes
in interfaceJackrabbitNodeTypeManager
- Throws:
SAXException
RepositoryException
-
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.- Specified by:
registerNodeTypes
in interfaceJackrabbitNodeTypeManager
- Throws:
IOException
RepositoryException
-
hasNodeType
public boolean hasNodeType(String name) throws RepositoryException
Checks whether a node type with the given name exists.- Specified by:
hasNodeType
in interfaceJackrabbitNodeTypeManager
- Specified by:
hasNodeType
in interfaceNodeTypeManager
- 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 specifiedCollection
ofNodeTypeDefinition
objects. This method is used to register or update a set of node types with mutual dependencies. Returns an iterator over the resultingNodeType
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 aNodeTypeDefinition
within theCollection
is invalid or if theCollection
contains an object of a type other thanNodeTypeDefinition
.Throws a
NodeTypeExistsException
ifallowUpdate
isfalse
and aNodeTypeDefinition
within theCollection
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 interfaceNodeTypeManager
- Parameters:
definitions
- a collection ofNodeTypeDefinition
sallowUpdate
- a boolean- Returns:
- the registered node types.
- Throws:
InvalidNodeTypeDefinitionException
- if aNodeTypeDefinition
within theCollection
is invalid or if theCollection
contains an object of a type other thanNodeTypeDefinition
.NodeTypeExistsException
- ifallowUpdate
isfalse
and aNodeTypeDefinition
within theCollection
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 interfaceNodeTypeManager
- Parameters:
names
- aString
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
-
-