Class NodeStateCopier.Builder
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.migration.NodeStateCopier.Builder
-
- Enclosing class:
- NodeStateCopier
public static class NodeStateCopier.Builder extends java.lang.Object
The NodeStateCopier.Builder allows configuring a NodeState copy operation withincludePaths
,excludePaths
andmergePaths
.
Include paths can define which paths should be copied from the source to the target.
Exclude paths allow restricting which paths should be copied. This is especially useful when there are individual nodes in an included path that should not be copied.
By default copying will remove items that already exist in the target but do not exist in the source. If this behaviour is undesired that is where merge paths come in.
Merge paths dictate in which parts of the tree the copy operation should be additive, i.e. the content from source is merged with the content in the target. Nodes that are present in the target but not in the source are then not deleted. However, in the case where nodes are present in both the source and the target, the node from the source is copied with its properties and any properties previously present on the target's node are lost.
Finally, using one of thecopy
methods, NodeStores or NodeStates can be copied.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
copy(@NotNull NodeState sourceRoot, @NotNull NodeBuilder targetRoot)
Creates a NodeStateCopier to copy thesourceRoot
NodeState to thetargetRoot
NodeBuilder, using any include, exclude, merge paths and consumer set on this NodeStateCopier.Builder.boolean
copy(@NotNull NodeStore source, @NotNull NodeStore target)
Creates a NodeStateCopier to copy thesource
NodeStore to thetarget
NodeStore, using any include, exclude, merge paths and consumer set on this NodeStateCopier.Builder.@NotNull NodeStateCopier.Builder
exclude(@NotNull java.lang.String... paths)
Convenience wrapper forexclude(Set)
.@NotNull NodeStateCopier.Builder
exclude(@NotNull java.util.Set<java.lang.String> paths)
Set exclude paths.@NotNull NodeStateCopier.Builder
excludeFragments(@NotNull java.lang.String... fragments)
Convenience wrapper forexclude(Set)
.@NotNull NodeStateCopier.Builder
excludeFragments(@NotNull java.util.Set<java.lang.String> fragments)
Set exclude fragments.@NotNull NodeStateCopier.Builder
include(@NotNull java.lang.String... paths)
Convenience wrapper forinclude(Set)
.@NotNull NodeStateCopier.Builder
include(@NotNull java.util.Set<java.lang.String> paths)
Set include paths.@NotNull NodeStateCopier.Builder
merge(@NotNull java.lang.String... paths)
Convenience wrapper formerge(Set)
.@NotNull NodeStateCopier.Builder
merge(@NotNull java.util.Set<java.lang.String> paths)
Set merge paths.@NotNull NodeStateCopier.Builder
preserve(@org.jetbrains.annotations.NotNull boolean preserveOnTarget)
Set if preserve paths on target@NotNull NodeStateCopier.Builder
supportFragment(@NotNull java.lang.String... paths)
Convenience wrapper forsupportFragment(Set)
.@NotNull NodeStateCopier.Builder
supportFragment(@NotNull java.util.Set<java.lang.String> paths)
Set fragment paths.NodeStateCopier.Builder
withNodeConsumer(@NotNull java.util.function.Consumer consumer)
Set consumer for node additions.@NotNull NodeStateCopier.Builder
withReferenceableFrozenNodes(boolean isReferenceable)
-
-
-
Method Detail
-
include
@NotNull public @NotNull NodeStateCopier.Builder include(@NotNull @NotNull java.util.Set<java.lang.String> paths)
Set include paths.- Parameters:
paths
- include paths- Returns:
- this Builder instance
- See Also:
NodeStateCopier(Set, Set, Set, Set, Set, boolean, boolean, Consumer)
-
include
@NotNull public @NotNull NodeStateCopier.Builder include(@NotNull @NotNull java.lang.String... paths)
Convenience wrapper forinclude(Set)
.- Parameters:
paths
- include paths- Returns:
- this Builder instance
- See Also:
NodeStateCopier(Set, Set, Set, Set, Set, boolean, boolean, Consumer)
-
preserve
@NotNull public @NotNull NodeStateCopier.Builder preserve(@NotNull @org.jetbrains.annotations.NotNull boolean preserveOnTarget)
Set if preserve paths on target- Parameters:
preserveOnTarget
- if paths on target are preserved if not present on source- Returns:
- this Builder instance
- See Also:
NodeStateCopier(Set, Set, Set, Set, Set, boolean, boolean, Consumer)
-
exclude
@NotNull public @NotNull NodeStateCopier.Builder exclude(@NotNull @NotNull java.util.Set<java.lang.String> paths)
Set exclude paths.- Parameters:
paths
- exclude paths- Returns:
- this Builder instance
- See Also:
NodeStateCopier(Set, Set, Set, Set, Set, boolean, boolean, Consumer)
-
exclude
@NotNull public @NotNull NodeStateCopier.Builder exclude(@NotNull @NotNull java.lang.String... paths)
Convenience wrapper forexclude(Set)
.- Parameters:
paths
- exclude paths- Returns:
- this Builder instance
- See Also:
NodeStateCopier(Set, Set, Set, Set, Set, boolean, boolean, Consumer)
-
supportFragment
@NotNull public @NotNull NodeStateCopier.Builder supportFragment(@NotNull @NotNull java.util.Set<java.lang.String> paths)
Set fragment paths.- Parameters:
paths
- fragment paths- Returns:
- this Builder instance
- See Also:
NodeStateCopier(Set, Set, Set, Set, Set, boolean, boolean, Consumer)
-
supportFragment
@NotNull public @NotNull NodeStateCopier.Builder supportFragment(@NotNull @NotNull java.lang.String... paths)
Convenience wrapper forsupportFragment(Set)
.- Parameters:
paths
- fragment paths- Returns:
- this Builder instance
- See Also:
NodeStateCopier(Set, Set, Set, Set, Set, boolean, boolean, Consumer)
-
excludeFragments
@NotNull public @NotNull NodeStateCopier.Builder excludeFragments(@NotNull @NotNull java.util.Set<java.lang.String> fragments)
Set exclude fragments.- Parameters:
fragments
- exclude fragments- Returns:
- this Builder instance
- See Also:
NodeStateCopier(Set, Set, Set, Set, Set, boolean, boolean, Consumer)
-
excludeFragments
@NotNull public @NotNull NodeStateCopier.Builder excludeFragments(@NotNull @NotNull java.lang.String... fragments)
Convenience wrapper forexclude(Set)
.- Parameters:
fragments
- exclude fragments- Returns:
- this Builder instance
- See Also:
NodeStateCopier(Set, Set, Set, Set, Set, boolean, boolean, Consumer)
-
merge
@NotNull public @NotNull NodeStateCopier.Builder merge(@NotNull @NotNull java.util.Set<java.lang.String> paths)
Set merge paths.- Parameters:
paths
- merge paths- Returns:
- this Builder instance
- See Also:
NodeStateCopier(Set, Set, Set, Set, Set, boolean, boolean, Consumer)
-
merge
@NotNull public @NotNull NodeStateCopier.Builder merge(@NotNull @NotNull java.lang.String... paths)
Convenience wrapper formerge(Set)
.- Parameters:
paths
- merge paths- Returns:
- this Builder instance
- See Also:
NodeStateCopier(Set, Set, Set, Set, Set, boolean, boolean, Consumer)
-
withReferenceableFrozenNodes
@NotNull public @NotNull NodeStateCopier.Builder withReferenceableFrozenNodes(boolean isReferenceable)
-
withNodeConsumer
public NodeStateCopier.Builder withNodeConsumer(@NotNull @NotNull java.util.function.Consumer consumer)
Set consumer for node additions.- Parameters:
consumer
- consumer to listen to path additions- Returns:
- this Builder instance
-
copy
public boolean copy(@NotNull @NotNull NodeState sourceRoot, @NotNull @NotNull NodeBuilder targetRoot)
Creates a NodeStateCopier to copy thesourceRoot
NodeState to thetargetRoot
NodeBuilder, using any include, exclude, merge paths and consumer set on this NodeStateCopier.Builder.
It is the responsibility of the caller to persist any changes using e.g.NodeStore.merge(NodeBuilder, CommitHook, CommitInfo)
.- Parameters:
sourceRoot
- NodeState to copy fromtargetRoot
- NodeBuilder to copy to- Returns:
- true if there were any changes, false if sourceRoot and targetRoot represent the same content
-
copy
public boolean copy(@NotNull @NotNull NodeStore source, @NotNull @NotNull NodeStore target) throws CommitFailedException
Creates a NodeStateCopier to copy thesource
NodeStore to thetarget
NodeStore, using any include, exclude, merge paths and consumer set on this NodeStateCopier.Builder.
Changes are automatically persisted with empty CommitHooks and CommitInfo viaNodeStore.merge(NodeBuilder, CommitHook, CommitInfo)
.- Parameters:
source
- NodeStore to copy fromtarget
- NodeStore to copy to- Returns:
- true if there were any changes, false if source and target represent the same content
- Throws:
CommitFailedException
- if the copy operation fails
-
-