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
ANodeTypeManagerImplimplements 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 newNodeTypeManagerImplinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispose()Disposes this node type manager.NodeTypeIteratorgetAllNodeTypes()NodeTypeIteratorgetMixinNodeTypes()NamePathResolvergetNamePathResolver()Returns the NamePathResolver used to validate JCR names.NodeDefinitionImplgetNodeDefinition(QNodeDefinition def)Retrieve theNodeDefinitionfor the givenQNodeDefinition.NodeTypegetNodeType(String nodeTypeName)NodeTypeImplgetNodeType(Name name)Return the node type with the specifiedntName.NodeTypeRegistrygetNodeTypeRegistry()NodeTypeIteratorgetPrimaryNodeTypes()PropertyDefinitionImplgetPropertyDefinition(QPropertyDefinition def)Retrieve thePropertyDefinitionfor the givenQPropertyDefinition.NodeDefinitionImplgetRootNodeDefinition()booleanhasNodeType(String name)Checks whether a node type with the given name exists.voidnodeTypeRegistered(Name ntName)Called when a node type has been registered.voidnodeTypeReRegistered(Name ntName)Called when a node type has been re-registered.voidnodeTypesUnregistered(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.NodeTypeIteratorregisterNodeTypes(NodeTypeDefinition[] definitions, boolean allowUpdate)Registers or updates the specifiedCollectionofNodeTypeDefinitionobjects.NodeType[]registerNodeTypes(InputSource in)Registers the node types defined in the given XML stream.StringtoString()voidunregisterNodeTypes(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 newNodeTypeManagerImplinstance.- 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:AbstractNodeTypeManagerRetrieve theNodeDefinitionfor the givenQNodeDefinition.- Specified by:
getNodeDefinitionin classAbstractNodeTypeManager- Parameters:
def- the QNodeDefinition- Returns:
- the node definition
-
getPropertyDefinition
public PropertyDefinitionImpl getPropertyDefinition(QPropertyDefinition def)
Description copied from class:AbstractNodeTypeManagerRetrieve thePropertyDefinitionfor the givenQPropertyDefinition.- Specified by:
getPropertyDefinitionin classAbstractNodeTypeManager- Parameters:
def- prop def- Returns:
- the property definition
-
getNodeType
public NodeTypeImpl getNodeType(Name name) throws NoSuchNodeTypeException
Description copied from class:AbstractNodeTypeManagerReturn the node type with the specifiedntName.- Specified by:
getNodeTypein 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:AbstractNodeTypeManagerReturns the NamePathResolver used to validate JCR names.- Specified by:
getNamePathResolverin 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:
nodeTypeRegisteredin 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:
nodeTypeReRegisteredin 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:
nodeTypesUnregisteredin interfaceNodeTypeRegistryListener- Parameters:
names- names of the types that have been unregistered
-
getAllNodeTypes
public NodeTypeIterator getAllNodeTypes() throws RepositoryException
- Specified by:
getAllNodeTypesin interfaceNodeTypeManager- Throws:
RepositoryException
-
getPrimaryNodeTypes
public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException
- Specified by:
getPrimaryNodeTypesin interfaceNodeTypeManager- Throws:
RepositoryException
-
getMixinNodeTypes
public NodeTypeIterator getMixinNodeTypes() throws RepositoryException
- Specified by:
getMixinNodeTypesin interfaceNodeTypeManager- Throws:
RepositoryException
-
getNodeType
public NodeType getNodeType(String nodeTypeName) throws NoSuchNodeTypeException
- Specified by:
getNodeTypein 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 existingNodeTypeReaderandNodeTypeRegistrymethods 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:
registerNodeTypesin interfaceJackrabbitNodeTypeManager- Throws:
SAXExceptionRepositoryException
-
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:
registerNodeTypesin interfaceJackrabbitNodeTypeManager- Throws:
IOExceptionRepositoryException
-
hasNodeType
public boolean hasNodeType(String name) throws RepositoryException
Checks whether a node type with the given name exists.- Specified by:
hasNodeTypein interfaceJackrabbitNodeTypeManager- Specified by:
hasNodeTypein interfaceNodeTypeManager- Parameters:
name- node type name- Returns:
trueif the named node type exists,falseotherwise- 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 specifiedCollectionofNodeTypeDefinitionobjects. This method is used to register or update a set of node types with mutual dependencies. Returns an iterator over the resultingNodeTypeobjects.The effect of the method is "all or nothing"; if an error occurs, no node types are registered or updated.
Throws an
InvalidNodeTypeDefinitionExceptionif aNodeTypeDefinitionwithin theCollectionis invalid or if theCollectioncontains an object of a type other thanNodeTypeDefinition.Throws a
NodeTypeExistsExceptionifallowUpdateisfalseand aNodeTypeDefinitionwithin theCollectionspecifies a node type name that is already registered.Throws an
UnsupportedRepositoryOperationExceptionif this implementation does not support node type registration.- Specified by:
registerNodeTypesin interfaceNodeTypeManager- Parameters:
definitions- a collection ofNodeTypeDefinitionsallowUpdate- a boolean- Returns:
- the registered node types.
- Throws:
InvalidNodeTypeDefinitionException- if aNodeTypeDefinitionwithin theCollectionis invalid or if theCollectioncontains an object of a type other thanNodeTypeDefinition.NodeTypeExistsException- ifallowUpdateisfalseand aNodeTypeDefinitionwithin theCollectionspecifies 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
NoSuchNodeTypeExceptionif one of the names listed is not a registered node type.Throws an
UnsupportedRepositoryOperationExceptionif this implementation does not support node type registration.- Specified by:
unregisterNodeTypesin interfaceNodeTypeManager- Parameters:
names- aStringarray- 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
-
-