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 Object implements NodeTypeManager, EffectiveNodeTypeProvider, DefinitionProvider
Base implementation of aNodeTypeManager
with support for reading node types from theTree
returned bygetTypes()
. Methods related to node type modifications throwUnsupportedRepositoryOperationException
.
-
-
Constructor Summary
Constructors Constructor Description ReadOnlyNodeTypeManager()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description NodeDefinitionTemplate
createNodeDefinitionTemplate()
NodeTypeTemplate
createNodeTypeTemplate()
NodeTypeTemplate
createNodeTypeTemplate(NodeTypeDefinition ntd)
PropertyDefinitionTemplate
createPropertyDefinitionTemplate()
NodeTypeIterator
getAllNodeTypes()
@NotNull NodeDefinition
getDefinition(@NotNull Tree parent, @NotNull String nodeName)
Returns the node definition for a child node ofparent
namednodeName
with a default primary type.@NotNull PropertyDefinition
getDefinition(@NotNull Tree parent, @NotNull PropertyState property, boolean exactTypeMatch)
Calculates the applicable definition for the property state under the given parent tree.@NotNull NodeDefinition
getDefinition(@NotNull Tree parent, @NotNull Tree targetNode)
Calculates the applicable definition for the child node under the given parent node.@NotNull EffectiveNodeType
getEffectiveNodeType(@NotNull Node node)
Returns all the node types of the given node, in a breadth-first traversal order of the type hierarchy.@NotNull EffectiveNodeType
getEffectiveNodeType(@NotNull Tree tree)
Calculates and returns the effective node types of the given tree.static @NotNull ReadOnlyNodeTypeManager
getInstance(Root root, NamePathMapper namePathMapper)
Return a new instance ofReadOnlyNodeTypeManager
that reads node type information from the tree atNodeTypeConstants.NODE_TYPES_PATH
.NodeTypeIterator
getMixinNodeTypes()
protected @NotNull NamePathMapper
getNamePathMapper()
Returns aNameMapper
to be used by this node type manager.NodeType
getNodeType(String name)
protected @NotNull String
getOakName(String jcrName)
Returns the internal name for the specified JCR name.NodeTypeIterator
getPrimaryNodeTypes()
@NotNull NodeDefinition
getRootDefinition()
protected abstract @NotNull Tree
getTypes()
Returns theTree
instance where the node types are stored.protected @Nullable ValueFactory
getValueFactory()
The value factory to be used byPropertyDefinition.getDefaultValues()
.boolean
hasNodeType(String name)
boolean
isNodeType(@NotNull String typeName, @NotNull String superName)
Returnstrue
iftypeName
is of the specified primary node type or mixin type, or a subtype thereof.boolean
isNodeType(@NotNull Tree tree, @NotNull String oakNtName)
Returnstrue
if this tree is of the specified primary node type or mixin type, or a subtype thereof respecting the effective node type of thetree
.boolean
isNodeType(@Nullable String primaryTypeName, @NotNull Supplier<Iterable<String>> mixinTypes, @NotNull String nodeTypeName)
Returnstrue
iftypeName
is of the specified primary node type or mixin type, or a subtype thereof.NodeType
registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate)
This implementation always throws aUnsupportedRepositoryOperationException
.NodeTypeIterator
registerNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate)
This implementation always throws aUnsupportedRepositoryOperationException
.void
unregisterNodeType(String name)
This implementation always throws aUnsupportedRepositoryOperationException
.void
unregisterNodeTypes(String[] names)
This implementation always throws aUnsupportedRepositoryOperationException
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.jackrabbit.oak.spi.nodetype.EffectiveNodeTypeProvider
isNodeType, isNodeType
-
-
-
-
Method Detail
-
getOakName
@NotNull protected final @NotNull String getOakName(String jcrName) throws RepositoryException
Returns the internal name for the specified JCR name.- Parameters:
jcrName
- JCR node type name.- Returns:
- the internal representation of the given JCR name.
- Throws:
RepositoryException
- If there is no valid internal representation of the specified JCR name.
-
getTypes
@NotNull protected abstract @NotNull Tree getTypes()
Returns theTree
instance where the node types are stored. This method never returnsnull
and may return aTree
that does not exist (seeTree.exists()
when there are no types stored.- Returns:
Tree
instance where the node types are stored.
-
getValueFactory
@Nullable protected @Nullable ValueFactory getValueFactory()
The value factory to be used byPropertyDefinition.getDefaultValues()
. Ifnull
the former returnsnull
.- Returns:
ValueFactory
instance ornull
.
-
getNamePathMapper
@NotNull protected @NotNull NamePathMapper getNamePathMapper()
Returns aNameMapper
to be used by this node type manager. This implementation returns theNamePathMapper.DEFAULT
instance. A subclass may override this method and provide a different implementation.- Returns:
NameMapper
instance.
-
getInstance
@NotNull public static @NotNull ReadOnlyNodeTypeManager getInstance(Root root, NamePathMapper namePathMapper)
Return a new instance ofReadOnlyNodeTypeManager
that reads node type information from the tree atNodeTypeConstants.NODE_TYPES_PATH
.- Parameters:
root
- The root to read node types from.namePathMapper
- TheNamePathMapper
to use.- Returns:
- a new instance of
ReadOnlyNodeTypeManager
.
-
hasNodeType
public boolean hasNodeType(String name) throws RepositoryException
- Specified by:
hasNodeType
in interfaceNodeTypeManager
- Throws:
RepositoryException
-
getNodeType
public NodeType getNodeType(String name) throws RepositoryException
- Specified by:
getNodeType
in interfaceNodeTypeManager
- Throws:
RepositoryException
-
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
-
createNodeTypeTemplate
public NodeTypeTemplate createNodeTypeTemplate() throws RepositoryException
- Specified by:
createNodeTypeTemplate
in interfaceNodeTypeManager
- Throws:
RepositoryException
-
createNodeTypeTemplate
public NodeTypeTemplate createNodeTypeTemplate(NodeTypeDefinition ntd) throws RepositoryException
- Specified by:
createNodeTypeTemplate
in interfaceNodeTypeManager
- Throws:
RepositoryException
-
createNodeDefinitionTemplate
public NodeDefinitionTemplate createNodeDefinitionTemplate() throws RepositoryException
- Specified by:
createNodeDefinitionTemplate
in interfaceNodeTypeManager
- Throws:
RepositoryException
-
createPropertyDefinitionTemplate
public PropertyDefinitionTemplate createPropertyDefinitionTemplate() throws RepositoryException
- Specified by:
createPropertyDefinitionTemplate
in interfaceNodeTypeManager
- Throws:
RepositoryException
-
registerNodeType
public NodeType registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate) throws RepositoryException
This implementation always throws aUnsupportedRepositoryOperationException
.- Specified by:
registerNodeType
in interfaceNodeTypeManager
- Throws:
RepositoryException
-
registerNodeTypes
public NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate) throws RepositoryException
This implementation always throws aUnsupportedRepositoryOperationException
.- Specified by:
registerNodeTypes
in interfaceNodeTypeManager
- Throws:
RepositoryException
-
unregisterNodeType
public void unregisterNodeType(String name) throws RepositoryException
This implementation always throws aUnsupportedRepositoryOperationException
.- Specified by:
unregisterNodeType
in interfaceNodeTypeManager
- Throws:
RepositoryException
-
unregisterNodeTypes
public void unregisterNodeTypes(String[] names) throws RepositoryException
This implementation always throws aUnsupportedRepositoryOperationException
.- Specified by:
unregisterNodeTypes
in interfaceNodeTypeManager
- Throws:
RepositoryException
-
isNodeType
public boolean isNodeType(@NotNull @NotNull Tree tree, @NotNull @NotNull String oakNtName)
Description copied from interface:EffectiveNodeTypeProvider
Returnstrue
if this tree is of the specified primary node type or mixin type, or a subtype thereof respecting the effective node type of thetree
. Returnsfalse
otherwise. 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:mixinTypes
property.- Specified by:
isNodeType
in 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 String primaryTypeName, @NotNull @NotNull Supplier<Iterable<String>> mixinTypes, @NotNull @NotNull String nodeTypeName)
Description copied from interface:EffectiveNodeTypeProvider
Returnstrue
iftypeName
is of the specified primary node type or mixin type, or a subtype thereof. Returnsfalse
otherwise.- Specified by:
isNodeType
in 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:
true
if the specified node type is of the given node type.
-
isNodeType
public boolean isNodeType(@NotNull @NotNull String typeName, @NotNull @NotNull String superName)
Description copied from interface:EffectiveNodeTypeProvider
Returnstrue
iftypeName
is of the specified primary node type or mixin type, or a subtype thereof. Returnsfalse
otherwise.- Specified by:
isNodeType
in 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:
true
if 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:
getEffectiveNodeType
in 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:EffectiveNodeTypeProvider
Calculates 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:
getEffectiveNodeType
in 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:
getRootDefinition
in interfaceDefinitionProvider
- Throws:
RepositoryException
-
getDefinition
@NotNull public @NotNull NodeDefinition getDefinition(@NotNull @NotNull Tree parent, @NotNull @NotNull String nodeName) throws RepositoryException
Description copied from interface:DefinitionProvider
Returns the node definition for a child node ofparent
namednodeName
with a default primary type. First the non-residual child node definitions ofparent
are checked matching the given node name. Then the residual definitions are checked.- Specified by:
getDefinition
in 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:DefinitionProvider
Calculates the applicable definition for the child node under the given parent node.- Specified by:
getDefinition
in 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:DefinitionProvider
Calculates the applicable definition for the property state under the given parent tree.- Specified by:
getDefinition
in 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.
-
-