Class TypeEditor
- java.lang.Object
-
- org.apache.jackrabbit.oak.spi.commit.DefaultEditor
-
- org.apache.jackrabbit.oak.plugins.nodetype.TypeEditor
-
- All Implemented Interfaces:
Editor
public class TypeEditor extends DefaultEditor
Validator implementation that check JCR node type constraints. TODO: check protected properties and the structure they enforce. some of those checks may have to go into separate validator classes. This class should only perform checks based on node type information. E.g. it cannot and should not check whether the value of the protected jcr:uuid is unique.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
TypeEditor.ConstraintViolationCallback
Extension point that allows pluggable handling of constraint violations
-
Field Summary
Fields Modifier and Type Field Description static TypeEditor.ConstraintViolationCallback
THROW_ON_CONSTRAINT_VIOLATION
static TypeEditor.ConstraintViolationCallback
WARN_ON_CONSTRAINT_VIOLATION
-
Fields inherited from class org.apache.jackrabbit.oak.spi.commit.DefaultEditor
INSTANCE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Editor
childNodeAdded(java.lang.String name, NodeState after)
Processes an added child node.TypeEditor
childNodeChanged(java.lang.String name, NodeState before, NodeState after)
Processes a changed child node.Editor
childNodeDeleted(java.lang.String name, NodeState before)
Processes a deleted child node.static TypeEditor
create(@NotNull TypeEditor.ConstraintViolationCallback callback, java.util.Set<java.lang.String> typesToCheck, @NotNull NodeState types, java.lang.String primary, java.lang.Iterable<java.lang.String> mixins, @NotNull NodeBuilder builder)
Creates a new TypeEditor instancevoid
enter(NodeState before, NodeState after)
Called before the given before and after states are compared.void
propertyAdded(PropertyState after)
Processes an added property.void
propertyChanged(PropertyState before, PropertyState after)
Processes a changed property.void
propertyDeleted(PropertyState before)
Processes a removed property.-
Methods inherited from class org.apache.jackrabbit.oak.spi.commit.DefaultEditor
leave
-
-
-
-
Field Detail
-
THROW_ON_CONSTRAINT_VIOLATION
public static final TypeEditor.ConstraintViolationCallback THROW_ON_CONSTRAINT_VIOLATION
-
WARN_ON_CONSTRAINT_VIOLATION
public static final TypeEditor.ConstraintViolationCallback WARN_ON_CONSTRAINT_VIOLATION
-
-
Method Detail
-
create
public static TypeEditor create(@NotNull @NotNull TypeEditor.ConstraintViolationCallback callback, java.util.Set<java.lang.String> typesToCheck, @NotNull @NotNull NodeState types, java.lang.String primary, java.lang.Iterable<java.lang.String> mixins, @NotNull @NotNull NodeBuilder builder) throws CommitFailedException
Creates a new TypeEditor instance- Parameters:
callback
- the callback to use when a constraint violation is found. The client must check the results of the callback invocations if the specified callback does not immediately propagate constraint violations as checked exceptions.typesToCheck
- the types to check for. Ifnull
, this node is checked. Otherwise it is checked if its primary type or one of it's mixin types is contained in this parameterstypes
- the/jcr:system/jcr:nodeTypes
nodeprimary
- the node's primary typemixins
- the node's mixinsbuilder
- a builder containing the current state of the node to check. May be used to set a default primary type if none is set- Returns:
- a new TypeEditor instance
- Throws:
CommitFailedException
- when the primary type of mixin definition is incorrect
-
propertyAdded
public void propertyAdded(PropertyState after) throws CommitFailedException
Description copied from interface:Editor
Processes an added property.- Specified by:
propertyAdded
in interfaceEditor
- Overrides:
propertyAdded
in classDefaultEditor
- Parameters:
after
- the added property- Throws:
CommitFailedException
- if processing failed
-
propertyChanged
public void propertyChanged(PropertyState before, PropertyState after) throws CommitFailedException
Description copied from interface:Editor
Processes a changed property.- Specified by:
propertyChanged
in interfaceEditor
- Overrides:
propertyChanged
in classDefaultEditor
- Parameters:
before
- the original propertyafter
- the changed property- Throws:
CommitFailedException
- if processing failed
-
propertyDeleted
public void propertyDeleted(PropertyState before) throws CommitFailedException
Description copied from interface:Editor
Processes a removed property.- Specified by:
propertyDeleted
in interfaceEditor
- Overrides:
propertyDeleted
in classDefaultEditor
- Parameters:
before
- the removed property- Throws:
CommitFailedException
- if processing failed
-
enter
public void enter(NodeState before, NodeState after) throws CommitFailedException
Description copied from interface:Editor
Called before the given before and after states are compared. The implementation can use this method to initialize any internal state needed for processing the results of the comparison. For example an implementation could look up the effective node type of the after state to know what constraints to apply to on the content changes.- Specified by:
enter
in interfaceEditor
- Overrides:
enter
in classDefaultEditor
- Parameters:
before
- before state, non-existent if this node was addedafter
- after state, non-existent if this node was removed- Throws:
CommitFailedException
- if this commit should be rejected
-
childNodeAdded
public Editor childNodeAdded(java.lang.String name, NodeState after) throws CommitFailedException
Description copied from interface:Editor
Processes an added child node.- Specified by:
childNodeAdded
in interfaceEditor
- Overrides:
childNodeAdded
in classDefaultEditor
- Parameters:
name
- name of the added nodeafter
- the added child node- Returns:
- an editor for processing the subtree below the added node,
or
null
if the subtree does not need processing - Throws:
CommitFailedException
- if processing failed
-
childNodeChanged
public TypeEditor childNodeChanged(java.lang.String name, NodeState before, NodeState after) throws CommitFailedException
Description copied from interface:Editor
Processes a changed child node. This method gets called for all child nodes that may contain changes between the before and after states.- Specified by:
childNodeChanged
in interfaceEditor
- Overrides:
childNodeChanged
in classDefaultEditor
- Parameters:
name
- name of the changed nodebefore
- child node before the changeafter
- child node after the change- Returns:
- an editor for processing the subtree below the added node,
or
null
if the subtree does not need processing - Throws:
CommitFailedException
- if processing failed
-
childNodeDeleted
public Editor childNodeDeleted(java.lang.String name, NodeState before) throws CommitFailedException
Description copied from interface:Editor
Processes a deleted child node.- Specified by:
childNodeDeleted
in interfaceEditor
- Overrides:
childNodeDeleted
in classDefaultEditor
- Parameters:
name
- name of the deleted nodebefore
- the deleted child node- Returns:
- an editor for processing the subtree below the removed node,
or
null
if the subtree does not need processing - Throws:
CommitFailedException
- if processing failed
-
-