Class NodeStateCopier
java.lang.Object
org.apache.jackrabbit.oak.plugins.migration.NodeStateCopier
The NodeStateCopier and NodeStateCopier.Builder classes allow
recursively copying a NodeState to a NodeBuilder.
The copy algorithm is optimized for copying nodes between two different NodeStore instances, i.e. where comparing NodeStates is imprecise and/or expensive.
The algorithm does a post-order traversal. I.e. it copies changed leaf-nodes first.
The work for a traversal without any differences between
Usage: For most use-cases the Builder API should be preferred. It allows setting
Include paths: if include paths are set, only these paths and their sub-trees are copied. Any nodes that are not within the scope of an include path are implicitly excluded.
Exclude paths: if exclude paths are set, any nodes matching or below the excluded path are not copied. If an excluded node does exist in the target, it is removed (see also merge paths). Exclude fragments: if exclude fragments are set, nodes with names matching any of the fragments (and their subtrees) are not copied. If an excluded node does exist in the target, it is removed. Merge paths: if merge paths are set, any nodes matching or below the merged path will not be deleted from target, even if they are missing in (or excluded from) the source. Preserve on Target if set to true the nodes on target under the included paths are not deleted and the merge paths property is ignored. If false the deletion rules default to the case for merge paths.
The copy algorithm is optimized for copying nodes between two different NodeStore instances, i.e. where comparing NodeStates is imprecise and/or expensive.
The algorithm does a post-order traversal. I.e. it copies changed leaf-nodes first.
The work for a traversal without any differences between
source
and target
is equivalent to the single
execution of a naive equals implementation.
Usage: For most use-cases the Builder API should be preferred. It allows setting
includePaths
,
excludePaths
and mergePaths
.
Include paths: if include paths are set, only these paths and their sub-trees are copied. Any nodes that are not within the scope of an include path are implicitly excluded.
Exclude paths: if exclude paths are set, any nodes matching or below the excluded path are not copied. If an excluded node does exist in the target, it is removed (see also merge paths). Exclude fragments: if exclude fragments are set, nodes with names matching any of the fragments (and their subtrees) are not copied. If an excluded node does exist in the target, it is removed. Merge paths: if merge paths are set, any nodes matching or below the merged path will not be deleted from target, even if they are missing in (or excluded from) the source. Preserve on Target if set to true the nodes on target under the included paths are not deleted and the merge paths property is ignored. If false the deletion rules default to the case for merge paths.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
The NodeStateCopier.Builder allows configuring a NodeState copy operation withincludePaths
,excludePaths
andmergePaths
. -
Method Summary
Modifier and TypeMethodDescriptionstatic NodeStateCopier.Builder
builder()
Create a NodeStateCopier.Builder.static boolean
copyNodeStore
(@NotNull NodeStore source, @NotNull NodeStore target) Shorthand method to copy one NodeStore to another.static boolean
copyProperties
(NodeState source, NodeBuilder target) Copies all changed properties from the source NodeState to the target NodeBuilder instance.static boolean
copyProperties
(NodeState source, NodeBuilder target, boolean preserveOnTarget, String path) Copies all changed properties from the source NodeState to the target NodeBuilder instance.
-
Method Details
-
builder
Create a NodeStateCopier.Builder.- Returns:
- a NodeStateCopier.Builder
- See Also:
-
copyNodeStore
public static boolean copyNodeStore(@NotNull @NotNull NodeStore source, @NotNull @NotNull NodeStore target) throws CommitFailedException Shorthand method to copy one NodeStore to another. The changes in the target NodeStore are automatically persisted.- Parameters:
source
- NodeStore to copy from.target
- NodeStore to copy to.- Returns:
- true if the target has been modified
- Throws:
CommitFailedException
- if the operation fails- See Also:
-
copyProperties
public static boolean copyProperties(NodeState source, NodeBuilder target, boolean preserveOnTarget, String path) Copies all changed properties from the source NodeState to the target NodeBuilder instance.- Parameters:
source
- The NodeState to copy from.target
- The NodeBuilder to copy to.preserveOnTarget
- boolean to indicate no changes on target except additionspath
- current path- Returns:
- Whether changes were made or not.
-
copyProperties
Copies all changed properties from the source NodeState to the target NodeBuilder instance.- Parameters:
source
- The NodeState to copy from.target
- The NodeBuilder to copy to.- Returns:
- Whether changes were made or not.
-