Class ReadWriteNodeTypeManager
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager
-
- org.apache.jackrabbit.oak.plugins.nodetype.write.ReadWriteNodeTypeManager
-
- All Implemented Interfaces:
NodeTypeManager
,DefinitionProvider
,EffectiveNodeTypeProvider
public abstract class ReadWriteNodeTypeManager extends ReadOnlyNodeTypeManager
ReadWriteNodeTypeManager
extends theReadOnlyNodeTypeManager
with support for operations that modify node types.registerNodeType(NodeTypeDefinition, boolean)
registerNodeTypes(NodeTypeDefinition[], boolean)
unregisterNodeType(String)
unregisterNodeTypes(String[])
- plus related template factory methods
refresh()
callback to e.g. inform an associated session that it should refresh to make the changes visible.Subclass responsibility is to provide an implementation of
ReadOnlyNodeTypeManager.getTypes()
for read only access to the tree where node types are stored in content andgetWriteRoot()
for write access to the repository in order to modify node types stored in content. A subclass may also want to override the default implementation ofReadOnlyNodeTypeManager
for the following methods:
-
-
Constructor Summary
Constructors Constructor Description ReadWriteNodeTypeManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NodeDefinitionTemplate
createNodeDefinitionTemplate()
Returns an emptyNodeDefinitionTemplate
which can then be used to create a child node definition and attached to aNodeTypeTemplate
.NodeTypeTemplate
createNodeTypeTemplate()
Returns an emptyNodeTypeTemplate
which can then be used to define a node type and passed toNodeTypeManager.registerNodeType
.NodeTypeTemplate
createNodeTypeTemplate(NodeTypeDefinition ntd)
Returns aNodeTypeTemplate
from the given definition, which can then be used to define a node type and passed toNodeTypeManager.registerNodeType
.PropertyDefinitionTemplate
createPropertyDefinitionTemplate()
Returns an emptyPropertyDefinitionTemplate
which can then be used to create a property definition and attached to aNodeTypeTemplate
.protected @NotNull Root
getWriteRoot()
Called by the methodsregisterNodeType(NodeTypeDefinition, boolean)
,registerNodeTypes(NodeTypeDefinition[], boolean)
,unregisterNodeType(String)
andunregisterNodeTypes(String[])
to acquire a freshRoot
instance that can be used to persist the requested node type changes (and nothing else).protected void
refresh()
Called by theReadWriteNodeTypeManager
implementation methods to refresh the state of the session associated with this instance.NodeType
registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate)
Registers a new node type or updates an existing node type using the specified definition and returns the resultingNodeType
object.NodeTypeIterator
registerNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate)
Registers or updates the specified array ofNodeTypeDefinition
objects.void
unregisterNodeType(String name)
Unregisters the specified node type.void
unregisterNodeTypes(String[] names)
Unregisters the specified set of node types.-
Methods inherited from class org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager
getAllNodeTypes, getDefinition, getDefinition, getDefinition, getEffectiveNodeType, getEffectiveNodeType, getInstance, getMixinNodeTypes, getNamePathMapper, getNodeType, getOakName, getPrimaryNodeTypes, getRootDefinition, getTypes, getValueFactory, hasNodeType, isNodeType, isNodeType, isNodeType
-
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
-
getWriteRoot
@NotNull protected @NotNull Root getWriteRoot()
Called by the methodsregisterNodeType(NodeTypeDefinition, boolean)
,registerNodeTypes(NodeTypeDefinition[], boolean)
,unregisterNodeType(String)
andunregisterNodeTypes(String[])
to acquire a freshRoot
instance that can be used to persist the requested node type changes (and nothing else).This default implementation throws an
UnsupportedOperationException
.- Returns:
- fresh
Root
instance.
-
refresh
protected void refresh() throws RepositoryException
Called by theReadWriteNodeTypeManager
implementation methods to refresh the state of the session associated with this instance. That way the session is kept in sync with the latest global state seen by the node type manager.- Throws:
RepositoryException
- if the session could not be refreshed
-
createNodeTypeTemplate
public NodeTypeTemplate createNodeTypeTemplate()
Returns an emptyNodeTypeTemplate
which can then be used to define a node type and passed toNodeTypeManager.registerNodeType
.- Specified by:
createNodeTypeTemplate
in interfaceNodeTypeManager
- Overrides:
createNodeTypeTemplate
in classReadOnlyNodeTypeManager
- Returns:
- A new empty
NodeTypeTemplate
. - Since:
- JCR 2.0
-
createNodeTypeTemplate
public NodeTypeTemplate createNodeTypeTemplate(NodeTypeDefinition ntd) throws ConstraintViolationException
Returns aNodeTypeTemplate
from the given definition, which can then be used to define a node type and passed toNodeTypeManager.registerNodeType
.- Specified by:
createNodeTypeTemplate
in interfaceNodeTypeManager
- Overrides:
createNodeTypeTemplate
in classReadOnlyNodeTypeManager
- Returns:
- A new
NodeTypeTemplate
. - Throws:
ConstraintViolationException
- Since:
- JCR 2.0
-
createNodeDefinitionTemplate
public NodeDefinitionTemplate createNodeDefinitionTemplate()
Returns an emptyNodeDefinitionTemplate
which can then be used to create a child node definition and attached to aNodeTypeTemplate
.- Specified by:
createNodeDefinitionTemplate
in interfaceNodeTypeManager
- Overrides:
createNodeDefinitionTemplate
in classReadOnlyNodeTypeManager
- Returns:
- A new
NodeDefinitionTemplate
. - Since:
- JCR 2.0
-
createPropertyDefinitionTemplate
public PropertyDefinitionTemplate createPropertyDefinitionTemplate()
Returns an emptyPropertyDefinitionTemplate
which can then be used to create a property definition and attached to aNodeTypeTemplate
.- Specified by:
createPropertyDefinitionTemplate
in interfaceNodeTypeManager
- Overrides:
createPropertyDefinitionTemplate
in classReadOnlyNodeTypeManager
- Returns:
- A new
PropertyDefinitionTemplate
. - Since:
- JCR 2.0
-
registerNodeType
public NodeType registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate) throws RepositoryException
Registers a new node type or updates an existing node type using the specified definition and returns the resultingNodeType
object.Typically, the object passed to this method will be a
NodeTypeTemplate
(a subclass ofNodeTypeDefinition
) acquired fromNodeTypeManager.createNodeTypeTemplate
and then filled-in with definition information.- Specified by:
registerNodeType
in interfaceNodeTypeManager
- Overrides:
registerNodeType
in classReadOnlyNodeTypeManager
- Parameters:
ntd
- anNodeTypeDefinition
.allowUpdate
- a boolean- Returns:
- the registered node type
- Throws:
NodeTypeExistsException
- ifallowUpdate
isfalse
and theNodeTypeDefinition
specifies a node type name that is already registered.RepositoryException
- if another error occurs.- Since:
- JCR 2.0
-
registerNodeTypes
public final NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate) throws RepositoryException
Registers or updates the specified array 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.
- Specified by:
registerNodeTypes
in interfaceNodeTypeManager
- Overrides:
registerNodeTypes
in classReadOnlyNodeTypeManager
- Parameters:
ntds
- a collection ofNodeTypeDefinition
sallowUpdate
- a boolean- Returns:
- the registered node types.
- Throws:
NodeTypeExistsException
- ifallowUpdate
isfalse
and aNodeTypeDefinition
within theCollection
specifies a node type name that is already registered.RepositoryException
- if another error occurs.- Since:
- JCR 2.0
-
unregisterNodeType
public void unregisterNodeType(String name) throws RepositoryException
Unregisters the specified node type.- Specified by:
unregisterNodeType
in interfaceNodeTypeManager
- Overrides:
unregisterNodeType
in classReadOnlyNodeTypeManager
- Parameters:
name
- aString
.- Throws:
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 RepositoryException
Unregisters the specified set of node types. Used to unregister a set of node types with mutual dependencies.- Specified by:
unregisterNodeTypes
in interfaceNodeTypeManager
- Overrides:
unregisterNodeTypes
in classReadOnlyNodeTypeManager
- Parameters:
names
- aString
array- Throws:
NoSuchNodeTypeException
- if one of the names listed is not a registered node type.RepositoryException
- if another error occurs.- Since:
- JCR 2.0
-
-