Class NodeStateCopier
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.migration.NodeStateCopier
-
public class NodeStateCopier extends java.lang.Object
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 betweensource
andtarget
is equivalent to the single execution of a naive equals implementation.
Usage: For most use-cases the Builder API should be preferred. It allows settingincludePaths
,excludePaths
andmergePaths
.
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 Classes Modifier and Type Class Description static class
NodeStateCopier.Builder
The NodeStateCopier.Builder allows configuring a NodeState copy operation withincludePaths
,excludePaths
andmergePaths
.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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.
-
-
-
Method Detail
-
builder
public static NodeStateCopier.Builder builder()
Create a NodeStateCopier.Builder.- Returns:
- a NodeStateCopier.Builder
- See Also:
NodeStateCopier.Builder
-
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:
NodeStateCopier.Builder.copy(NodeStore, NodeStore)
-
copyProperties
public static boolean copyProperties(NodeState source, NodeBuilder target)
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.
-
-