Class ReadOnlyNodeTypeManager
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager
-
- All Implemented Interfaces:
NodeTypeManager,DefinitionProvider,EffectiveNodeTypeProvider
- Direct Known Subclasses:
ReadWriteNodeTypeManager
public abstract class ReadOnlyNodeTypeManager extends java.lang.Object implements NodeTypeManager, EffectiveNodeTypeProvider, DefinitionProvider
Base implementation of aNodeTypeManagerwith support for reading node types from theTreereturned bygetTypes(). Methods related to node type modifications throwUnsupportedRepositoryOperationException.
-
-
Constructor Summary
Constructors Constructor Description ReadOnlyNodeTypeManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description NodeDefinitionTemplatecreateNodeDefinitionTemplate()Returns an emptyNodeDefinitionTemplatewhich can then be used to create a child node definition and attached to aNodeTypeTemplate.NodeTypeTemplatecreateNodeTypeTemplate()Returns an emptyNodeTypeTemplatewhich can then be used to define a node type and passed toNodeTypeManager.registerNodeType.NodeTypeTemplatecreateNodeTypeTemplate(NodeTypeDefinition ntd)Returns aNodeTypeTemplateholding the specified node type definition.PropertyDefinitionTemplatecreatePropertyDefinitionTemplate()Returns an emptyPropertyDefinitionTemplatewhich can then be used to create a property definition and attached to aNodeTypeTemplate.NodeTypeIteratorgetAllNodeTypes()Returns an iterator over all available node types (primary and mixin).@NotNull NodeDefinitiongetDefinition(@NotNull Tree parent, @NotNull java.lang.String nodeName)Returns the node definition for a child node ofparentnamednodeNamewith a default primary type.@NotNull PropertyDefinitiongetDefinition(@NotNull Tree parent, @NotNull PropertyState property, boolean exactTypeMatch)Calculates the applicable definition for the property state under the given parent tree.@NotNull NodeDefinitiongetDefinition(@NotNull Tree parent, @NotNull Tree targetNode)Calculates the applicable definition for the child node under the given parent node.@NotNull EffectiveNodeTypegetEffectiveNodeType(@NotNull Node node)Returns all the node types of the given node, in a breadth-first traversal order of the type hierarchy.@NotNull EffectiveNodeTypegetEffectiveNodeType(@NotNull Tree tree)Calculates and returns the effective node types of the given tree.static @NotNull ReadOnlyNodeTypeManagergetInstance(Root root, NamePathMapper namePathMapper)Return a new instance ofReadOnlyNodeTypeManagerthat reads node type information from the tree atNodeTypeConstants.NODE_TYPES_PATH.NodeTypeIteratorgetMixinNodeTypes()Returns an iterator over all available mixin node types.NodeTypegetNodeType(java.lang.String name)Returns the named node type.NodeTypeIteratorgetPrimaryNodeTypes()Returns an iterator over all available primary node types.@NotNull NodeDefinitiongetRootDefinition()booleanhasNodeType(java.lang.String name)Returnstrueif a node type with the specified name is registered.booleanisNodeType(@NotNull java.lang.String typeName, @NotNull java.lang.String superName)ReturnstrueiftypeNameis of the specified primary node type or mixin type, or a subtype thereof.booleanisNodeType(@NotNull Tree tree, @NotNull java.lang.String oakNtName)Returnstrueif this tree is of the specified primary node type or mixin type, or a subtype thereof respecting the effective node type of thetree.booleanisNodeType(@Nullable java.lang.String primaryTypeName, @NotNull java.lang.Iterable<java.lang.String> mixinTypes, @NotNull java.lang.String nodeTypeName)ReturnstrueiftypeNameis of the specified primary node type or mixin type, or a subtype thereof.NodeTyperegisterNodeType(NodeTypeDefinition ntd, boolean allowUpdate)This implementation always throws aUnsupportedRepositoryOperationException.NodeTypeIteratorregisterNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate)This implementation always throws aUnsupportedRepositoryOperationException.voidunregisterNodeType(java.lang.String name)This implementation always throws aUnsupportedRepositoryOperationException.voidunregisterNodeTypes(java.lang.String[] names)This implementation always throws aUnsupportedRepositoryOperationException.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.jackrabbit.oak.spi.nodetype.EffectiveNodeTypeProvider
isNodeType
-
-
-
-
Method Detail
-
getInstance
@NotNull public static @NotNull ReadOnlyNodeTypeManager getInstance(Root root, NamePathMapper namePathMapper)
Return a new instance ofReadOnlyNodeTypeManagerthat reads node type information from the tree atNodeTypeConstants.NODE_TYPES_PATH.- Parameters:
root- The root to read node types from.namePathMapper- TheNamePathMapperto use.- Returns:
- a new instance of
ReadOnlyNodeTypeManager.
-
hasNodeType
public boolean hasNodeType(java.lang.String name) throws RepositoryExceptionDescription copied from interface:NodeTypeManagerReturnstrueif a node type with the specified name is registered. Returnsfalseotherwise.- Specified by:
hasNodeTypein interfaceNodeTypeManager- Parameters:
name- aString.- Returns:
- a
boolean - Throws:
RepositoryException- if an error occurs.
-
getNodeType
public NodeType getNodeType(java.lang.String name) throws RepositoryException
Description copied from interface:NodeTypeManagerReturns the named node type.- Specified by:
getNodeTypein interfaceNodeTypeManager- Parameters:
name- the name of an existing node type.- Returns:
- A
NodeTypeobject. - Throws:
NoSuchNodeTypeException- if no node type by the given name exists.RepositoryException- if another error occurs.
-
getAllNodeTypes
public NodeTypeIterator getAllNodeTypes() throws RepositoryException
Description copied from interface:NodeTypeManagerReturns an iterator over all available node types (primary and mixin).- Specified by:
getAllNodeTypesin interfaceNodeTypeManager- Returns:
- An
NodeTypeIterator. - Throws:
RepositoryException- if an error occurs.
-
getPrimaryNodeTypes
public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException
Description copied from interface:NodeTypeManagerReturns an iterator over all available primary node types.- Specified by:
getPrimaryNodeTypesin interfaceNodeTypeManager- Returns:
- An
NodeTypeIterator. - Throws:
RepositoryException- if an error occurs.
-
getMixinNodeTypes
public NodeTypeIterator getMixinNodeTypes() throws RepositoryException
Description copied from interface:NodeTypeManagerReturns an iterator over all available mixin node types. If none are available, an empty iterator is returned.- Specified by:
getMixinNodeTypesin interfaceNodeTypeManager- Returns:
- An
NodeTypeIterator. - Throws:
RepositoryException- if an error occurs.
-
createNodeTypeTemplate
public NodeTypeTemplate createNodeTypeTemplate() throws RepositoryException
Description copied from interface:NodeTypeManagerReturns an emptyNodeTypeTemplatewhich can then be used to define a node type and passed toNodeTypeManager.registerNodeType.- Specified by:
createNodeTypeTemplatein interfaceNodeTypeManager- Returns:
- A
NodeTypeTemplate. - Throws:
UnsupportedRepositoryOperationException- if this implementation does not support node type registration.RepositoryException- if another error occurs.
-
createNodeTypeTemplate
public NodeTypeTemplate createNodeTypeTemplate(NodeTypeDefinition ntd) throws RepositoryException
Description copied from interface:NodeTypeManagerReturns aNodeTypeTemplateholding the specified node type definition. This template can then be altered and passed toNodeTypeManager.registerNodeType.- Specified by:
createNodeTypeTemplatein interfaceNodeTypeManager- Parameters:
ntd- aNodeTypeDefinition.- Returns:
- A
NodeTypeTemplate. - Throws:
UnsupportedRepositoryOperationException- if this implementation does not support node type registration.RepositoryException- if another error occurs.
-
createNodeDefinitionTemplate
public NodeDefinitionTemplate createNodeDefinitionTemplate() throws RepositoryException
Description copied from interface:NodeTypeManagerReturns an emptyNodeDefinitionTemplatewhich can then be used to create a child node definition and attached to aNodeTypeTemplate.- Specified by:
createNodeDefinitionTemplatein interfaceNodeTypeManager- Returns:
- A
NodeDefinitionTemplate. - Throws:
UnsupportedRepositoryOperationException- if this implementation does not support node type registration.RepositoryException- if another error occurs.
-
createPropertyDefinitionTemplate
public PropertyDefinitionTemplate createPropertyDefinitionTemplate() throws RepositoryException
Description copied from interface:NodeTypeManagerReturns an emptyPropertyDefinitionTemplatewhich can then be used to create a property definition and attached to aNodeTypeTemplate.- Specified by:
createPropertyDefinitionTemplatein interfaceNodeTypeManager- Returns:
- A
PropertyDefinitionTemplate. - Throws:
UnsupportedRepositoryOperationException- if this implementation does not support node type registration.RepositoryException- if another error occurs.
-
registerNodeType
public NodeType registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate) throws RepositoryException
This implementation always throws aUnsupportedRepositoryOperationException.- Specified by:
registerNodeTypein interfaceNodeTypeManager- Parameters:
ntd- anNodeTypeDefinition.allowUpdate- a boolean- Returns:
- the registered node type
- Throws:
InvalidNodeTypeDefinitionException- if theNodeTypeDefinitionis invalid.NodeTypeExistsException- ifallowUpdateisfalseand theNodeTypeDefinitionspecifies a node type name that is already registered.UnsupportedRepositoryOperationException- if this implementation does not support node type registration.RepositoryException- if another error occurs.
-
registerNodeTypes
public NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate) throws RepositoryException
This implementation always throws aUnsupportedRepositoryOperationException.- Specified by:
registerNodeTypesin interfaceNodeTypeManager- Parameters:
ntds- 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.
-
unregisterNodeType
public void unregisterNodeType(java.lang.String name) throws RepositoryExceptionThis implementation always throws aUnsupportedRepositoryOperationException.- Specified by:
unregisterNodeTypein interfaceNodeTypeManager- Parameters:
name- aString.- 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.
-
unregisterNodeTypes
public void unregisterNodeTypes(java.lang.String[] names) throws RepositoryExceptionThis implementation always throws aUnsupportedRepositoryOperationException.- 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.
-
isNodeType
public boolean isNodeType(@NotNull @NotNull Tree tree, @NotNull @NotNull java.lang.String oakNtName)Description copied from interface:EffectiveNodeTypeProviderReturnstrueif this tree is of the specified primary node type or mixin type, or a subtype thereof respecting the effective node type of thetree. Returnsfalseotherwise. Note: caution must be taken while calling this api because it doesn't offer the same strict guarantees as theNode#isNodeType(String)method in the case where the session doesn't have access to thejcr:mixinTypesproperty.- Specified by:
isNodeTypein interfaceEffectiveNodeTypeProvider- Parameters:
tree- The tree to be tested.oakNtName- The internal oak name of the node type to be tested.- Returns:
- true if the specified node is of the given node type.
-
isNodeType
public boolean isNodeType(@Nullable @Nullable java.lang.String primaryTypeName, @NotNull @NotNull java.lang.Iterable<java.lang.String> mixinTypes, @NotNull @NotNull java.lang.String nodeTypeName)Description copied from interface:EffectiveNodeTypeProviderReturnstrueiftypeNameis of the specified primary node type or mixin type, or a subtype thereof. Returnsfalseotherwise.- Specified by:
isNodeTypein interfaceEffectiveNodeTypeProvider- Parameters:
primaryTypeName- the internal oak name of the node to testmixinTypes- the internal oak names of the node to test.nodeTypeName- The internal oak name of the node type to be tested.- Returns:
trueif the specified node type is of the given node type.
-
isNodeType
public boolean isNodeType(@NotNull @NotNull java.lang.String typeName, @NotNull @NotNull java.lang.String superName)Description copied from interface:EffectiveNodeTypeProviderReturnstrueiftypeNameis of the specified primary node type or mixin type, or a subtype thereof. Returnsfalseotherwise.- Specified by:
isNodeTypein interfaceEffectiveNodeTypeProvider- Parameters:
typeName- the internal oak name of the node type to testsuperName- The internal oak name of the super type to be tested for.- Returns:
trueif the specified node type is of the given node type.
-
getEffectiveNodeType
@NotNull public @NotNull EffectiveNodeType getEffectiveNodeType(@NotNull @NotNull Node node) throws RepositoryException
Returns all the node types of the given node, in a breadth-first traversal order of the type hierarchy.- Specified by:
getEffectiveNodeTypein interfaceEffectiveNodeTypeProvider- Parameters:
node- node instance- Returns:
- all types of the given node
- Throws:
RepositoryException- if the type information can not be accessed- See Also:
- JCR 2.0 Specification, Section 3.7.6.5
-
getEffectiveNodeType
@NotNull public @NotNull EffectiveNodeType getEffectiveNodeType(@NotNull @NotNull Tree tree) throws RepositoryException
Description copied from interface:EffectiveNodeTypeProviderCalculates and returns the effective node types of the given tree. Also see JCR 2.0 Specification, Section 3.7.6.5 for the definition of the effective node type.- Specified by:
getEffectiveNodeTypein interfaceEffectiveNodeTypeProvider- Parameters:
tree- the tree- Returns:
- all node types of the given tree
- Throws:
RepositoryException- if the type information can not be accessed,- See Also:
- JCR 2.0 Specification, Section 3.7.6.5
-
getRootDefinition
@NotNull public @NotNull NodeDefinition getRootDefinition() throws RepositoryException
- Specified by:
getRootDefinitionin interfaceDefinitionProvider- Throws:
RepositoryException
-
getDefinition
@NotNull public @NotNull NodeDefinition getDefinition(@NotNull @NotNull Tree parent, @NotNull @NotNull java.lang.String nodeName) throws RepositoryException
Description copied from interface:DefinitionProviderReturns the node definition for a child node ofparentnamednodeNamewith a default primary type. First the non-residual child node definitions ofparentare checked matching the given node name. Then the residual definitions are checked.- Specified by:
getDefinitionin interfaceDefinitionProvider- Parameters:
parent- the parent node.nodeName- The internal oak name of the child node.- Returns:
- the applicable node definition.
- Throws:
ConstraintViolationException- If no matching definition can be found.RepositoryException- If another error occurs.
-
getDefinition
@NotNull public @NotNull NodeDefinition getDefinition(@NotNull @NotNull Tree parent, @NotNull @NotNull Tree targetNode) throws RepositoryException
Description copied from interface:DefinitionProviderCalculates the applicable definition for the child node under the given parent node.- Specified by:
getDefinitionin interfaceDefinitionProvider- Parameters:
parent- The parent node.targetNode- The child node for which the definition is calculated.- Returns:
- the definition of the target node.
- Throws:
ConstraintViolationException- If no matching definition can be found.RepositoryException- If another error occurs.
-
getDefinition
@NotNull public @NotNull PropertyDefinition getDefinition(@NotNull @NotNull Tree parent, @NotNull @NotNull PropertyState property, boolean exactTypeMatch) throws RepositoryException
Description copied from interface:DefinitionProviderCalculates the applicable definition for the property state under the given parent tree.- Specified by:
getDefinitionin interfaceDefinitionProvider- Parameters:
parent- The parent tree.property- The target property.- Returns:
- the definition for the target property.
- Throws:
ConstraintViolationException- If no matching definition can be found.RepositoryException- If another error occurs.
-
-