Class MoveDetector
- java.lang.Object
-
- org.apache.jackrabbit.oak.spi.state.MoveDetector
-
public class MoveDetector extends java.lang.Object implements Validator
AMoveDetector
is a validator that can detect certain move operations and reports these to the wrappedMoveValidator
by callingMoveValidator.move(String, String, NodeState)
. That method is called additional toMoveValidator.childNodeAdded(String, NodeState)
for the destination of the move operation andMoveValidator.childNodeDeleted(String, NodeState)
for the source of the move operation.Detection of move operations relies on the presence of the
SOURCE_PATH
property. New nodes with this property set have been moved from the path indicated by the value of the property to its current location.Limitations:
- Moving a moved node only reports one move from the original source to the final target.
- Moving a transiently added node is not reported as a move operation but as an add operation on the move target.
- Removing a moved node is not reported as a move operation but as a remove operation from the source of the move.
- Moving a child node of a transiently moved node is reported from the original source node, not from the intermediate one.
- Moving a node back and forth to its original location is not reported at all.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
SOURCE_PATH
-
Constructor Summary
Constructors Constructor Description MoveDetector(MoveValidator moveValidator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Validator
childNodeAdded(java.lang.String name, NodeState after)
Validate an added nodeValidator
childNodeChanged(java.lang.String name, NodeState before, NodeState after)
Validate a changed nodeValidator
childNodeDeleted(java.lang.String name, NodeState before)
Validate a deleted nodevoid
enter(NodeState before, NodeState after)
Called before the given before and after states are compared.void
leave(NodeState before, NodeState after)
Called after the given before and after states are compared.void
propertyAdded(PropertyState after)
Validate an added propertyvoid
propertyChanged(PropertyState before, PropertyState after)
Validate a changed propertyvoid
propertyDeleted(PropertyState before)
Validate a deleted property
-
-
-
Field Detail
-
SOURCE_PATH
public static final java.lang.String SOURCE_PATH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MoveDetector
public MoveDetector(MoveValidator moveValidator)
-
-
Method Detail
-
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
- 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
-
leave
public void leave(NodeState before, NodeState after) throws CommitFailedException
Description copied from interface:Editor
Called after the given before and after states are compared. The implementation can use this method to post-process information collected during the content diff. For example an implementation that during the diff just recorded the fact that this node was modified in some way could then use this method to trigger an index update based on that modification flag.- Specified by:
leave
in interfaceEditor
- 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
-
propertyAdded
public void propertyAdded(PropertyState after) throws CommitFailedException
Description copied from interface:Validator
Validate an added property- Specified by:
propertyAdded
in interfaceEditor
- Specified by:
propertyAdded
in interfaceValidator
- Parameters:
after
- the added property- Throws:
CommitFailedException
- if validation fails.
-
propertyChanged
public void propertyChanged(PropertyState before, PropertyState after) throws CommitFailedException
Description copied from interface:Validator
Validate a changed property- Specified by:
propertyChanged
in interfaceEditor
- Specified by:
propertyChanged
in interfaceValidator
- Parameters:
before
- the original propertyafter
- the changed property- Throws:
CommitFailedException
- if validation fails.
-
propertyDeleted
public void propertyDeleted(PropertyState before) throws CommitFailedException
Description copied from interface:Validator
Validate a deleted property- Specified by:
propertyDeleted
in interfaceEditor
- Specified by:
propertyDeleted
in interfaceValidator
- Parameters:
before
- the original property- Throws:
CommitFailedException
- if validation fails.
-
childNodeAdded
public Validator childNodeAdded(java.lang.String name, NodeState after) throws CommitFailedException
Description copied from interface:Validator
Validate an added node- Specified by:
childNodeAdded
in interfaceEditor
- Specified by:
childNodeAdded
in interfaceValidator
- Parameters:
name
- the name of the added nodeafter
- the added node- Returns:
- a
Validator
forafter
ornull
if validation should not decent into the subtree rooted atafter
. - Throws:
CommitFailedException
- if validation fails.
-
childNodeChanged
public Validator childNodeChanged(java.lang.String name, NodeState before, NodeState after) throws CommitFailedException
Description copied from interface:Validator
Validate a changed node- Specified by:
childNodeChanged
in interfaceEditor
- Specified by:
childNodeChanged
in interfaceValidator
- Parameters:
name
- the name of the changed nodebefore
- the original nodeafter
- the changed node- Returns:
- a
Validator
forafter
ornull
if validation should not decent into the subtree rooted atafter
. - Throws:
CommitFailedException
- if validation fails.
-
childNodeDeleted
public Validator childNodeDeleted(java.lang.String name, NodeState before) throws CommitFailedException
Description copied from interface:Validator
Validate a deleted node- Specified by:
childNodeDeleted
in interfaceEditor
- Specified by:
childNodeDeleted
in interfaceValidator
- Parameters:
name
- The name of the deleted node.before
- the original node- Returns:
- a
Validator
for the removed subtree ornull
if validation should not decent into the subtree - Throws:
CommitFailedException
- if validation fails.
-
-