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
ReadWriteNodeTypeManagerextends theReadOnlyNodeTypeManagerwith 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 ofReadOnlyNodeTypeManagerfor the following methods:
-
-
Constructor Summary
Constructors Constructor Description ReadWriteNodeTypeManager()
-
Method Summary
All 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 aNodeTypeTemplatefrom the given definition, which can then be used to define a node type and passed toNodeTypeManager.registerNodeType.PropertyDefinitionTemplatecreatePropertyDefinitionTemplate()Returns an emptyPropertyDefinitionTemplatewhich can then be used to create a property definition and attached to aNodeTypeTemplate.protected @NotNull RootgetWriteRoot()Called by the methodsregisterNodeType(NodeTypeDefinition, boolean),registerNodeTypes(NodeTypeDefinition[], boolean),unregisterNodeType(String)andunregisterNodeTypes(String[])to acquire a freshRootinstance that can be used to persist the requested node type changes (and nothing else).protected voidrefresh()Called by theReadWriteNodeTypeManagerimplementation methods to refresh the state of the session associated with this instance.NodeTyperegisterNodeType(NodeTypeDefinition ntd, boolean allowUpdate)Registers a new node type or updates an existing node type using the specified definition and returns the resultingNodeTypeobject.NodeTypeIteratorregisterNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate)Registers or updates the specified array ofNodeTypeDefinitionobjects.voidunregisterNodeType(String name)Unregisters the specified node type.voidunregisterNodeTypes(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 freshRootinstance that can be used to persist the requested node type changes (and nothing else).This default implementation throws an
UnsupportedOperationException.- Returns:
- fresh
Rootinstance.
-
refresh
protected void refresh() throws RepositoryExceptionCalled by theReadWriteNodeTypeManagerimplementation 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 emptyNodeTypeTemplatewhich can then be used to define a node type and passed toNodeTypeManager.registerNodeType.- Specified by:
createNodeTypeTemplatein interfaceNodeTypeManager- Overrides:
createNodeTypeTemplatein classReadOnlyNodeTypeManager- Returns:
- A new empty
NodeTypeTemplate. - Since:
- JCR 2.0
-
createNodeTypeTemplate
public NodeTypeTemplate createNodeTypeTemplate(NodeTypeDefinition ntd) throws ConstraintViolationException
Returns aNodeTypeTemplatefrom the given definition, which can then be used to define a node type and passed toNodeTypeManager.registerNodeType.- Specified by:
createNodeTypeTemplatein interfaceNodeTypeManager- Overrides:
createNodeTypeTemplatein classReadOnlyNodeTypeManager- Returns:
- A new
NodeTypeTemplate. - Throws:
ConstraintViolationException- Since:
- JCR 2.0
-
createNodeDefinitionTemplate
public NodeDefinitionTemplate createNodeDefinitionTemplate()
Returns an emptyNodeDefinitionTemplatewhich can then be used to create a child node definition and attached to aNodeTypeTemplate.- Specified by:
createNodeDefinitionTemplatein interfaceNodeTypeManager- Overrides:
createNodeDefinitionTemplatein classReadOnlyNodeTypeManager- Returns:
- A new
NodeDefinitionTemplate. - Since:
- JCR 2.0
-
createPropertyDefinitionTemplate
public PropertyDefinitionTemplate createPropertyDefinitionTemplate()
Returns an emptyPropertyDefinitionTemplatewhich can then be used to create a property definition and attached to aNodeTypeTemplate.- Specified by:
createPropertyDefinitionTemplatein interfaceNodeTypeManager- Overrides:
createPropertyDefinitionTemplatein 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 resultingNodeTypeobject.Typically, the object passed to this method will be a
NodeTypeTemplate(a subclass ofNodeTypeDefinition) acquired fromNodeTypeManager.createNodeTypeTemplateand then filled-in with definition information.- Specified by:
registerNodeTypein interfaceNodeTypeManager- Overrides:
registerNodeTypein classReadOnlyNodeTypeManager- Parameters:
ntd- anNodeTypeDefinition.allowUpdate- a boolean- Returns:
- the registered node type
- Throws:
NodeTypeExistsException- ifallowUpdateisfalseand theNodeTypeDefinitionspecifies 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 ofNodeTypeDefinitionobjects. 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.
- Specified by:
registerNodeTypesin interfaceNodeTypeManager- Overrides:
registerNodeTypesin classReadOnlyNodeTypeManager- Parameters:
ntds- a collection ofNodeTypeDefinitionsallowUpdate- a boolean- Returns:
- the registered node types.
- Throws:
NodeTypeExistsException- ifallowUpdateisfalseand aNodeTypeDefinitionwithin theCollectionspecifies 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:
unregisterNodeTypein interfaceNodeTypeManager- Overrides:
unregisterNodeTypein 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:
unregisterNodeTypesin interfaceNodeTypeManager- Overrides:
unregisterNodeTypesin classReadOnlyNodeTypeManager- Parameters:
names- aStringarray- Throws:
NoSuchNodeTypeException- if one of the names listed is not a registered node type.RepositoryException- if another error occurs.- Since:
- JCR 2.0
-
-