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 interfaceTypeEditor.ConstraintViolationCallbackExtension point that allows pluggable handling of constraint violations
-
Field Summary
Fields Modifier and Type Field Description static TypeEditor.ConstraintViolationCallbackTHROW_ON_CONSTRAINT_VIOLATIONstatic TypeEditor.ConstraintViolationCallbackWARN_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 EditorchildNodeAdded(String name, NodeState after)Processes an added child node.TypeEditorchildNodeChanged(String name, NodeState before, NodeState after)Processes a changed child node.EditorchildNodeDeleted(String name, NodeState before)Processes a deleted child node.static TypeEditorcreate(@NotNull TypeEditor.ConstraintViolationCallback callback, Set<String> typesToCheck, @NotNull NodeState types, String primary, Iterable<String> mixins, @NotNull NodeBuilder builder)Creates a new TypeEditor instancevoidenter(NodeState before, NodeState after)Called before the given before and after states are compared.voidpropertyAdded(PropertyState after)Processes an added property.voidpropertyChanged(PropertyState before, PropertyState after)Processes a changed property.voidpropertyDeleted(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, Set<String> typesToCheck, @NotNull @NotNull NodeState types, String primary, Iterable<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:nodeTypesnodeprimary- 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:EditorProcesses an added property.- Specified by:
propertyAddedin interfaceEditor- Overrides:
propertyAddedin 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:EditorProcesses a changed property.- Specified by:
propertyChangedin interfaceEditor- Overrides:
propertyChangedin 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:EditorProcesses a removed property.- Specified by:
propertyDeletedin interfaceEditor- Overrides:
propertyDeletedin 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:EditorCalled 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:
enterin interfaceEditor- Overrides:
enterin 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(String name, NodeState after) throws CommitFailedException
Description copied from interface:EditorProcesses an added child node.- Specified by:
childNodeAddedin interfaceEditor- Overrides:
childNodeAddedin classDefaultEditor- Parameters:
name- name of the added nodeafter- the added child node- Returns:
- an editor for processing the subtree below the added node,
or
nullif the subtree does not need processing - Throws:
CommitFailedException- if processing failed
-
childNodeChanged
public TypeEditor childNodeChanged(String name, NodeState before, NodeState after) throws CommitFailedException
Description copied from interface:EditorProcesses a changed child node. This method gets called for all child nodes that may contain changes between the before and after states.- Specified by:
childNodeChangedin interfaceEditor- Overrides:
childNodeChangedin 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
nullif the subtree does not need processing - Throws:
CommitFailedException- if processing failed
-
childNodeDeleted
public Editor childNodeDeleted(String name, NodeState before) throws CommitFailedException
Description copied from interface:EditorProcesses a deleted child node.- Specified by:
childNodeDeletedin interfaceEditor- Overrides:
childNodeDeletedin classDefaultEditor- Parameters:
name- name of the deleted nodebefore- the deleted child node- Returns:
- an editor for processing the subtree below the removed node,
or
nullif the subtree does not need processing - Throws:
CommitFailedException- if processing failed
-
-