public final class TreeUtil
extends java.lang.Object
Tree that are not provided
by the API.| Modifier and Type | Method and Description |
|---|---|
static @NotNull org.apache.jackrabbit.oak.api.Tree |
addChild(@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull java.lang.String childName,
@NotNull java.lang.String primaryTypeName)
Adds a new child tree with the given name and primary type name.
|
static @NotNull org.apache.jackrabbit.oak.api.Tree |
addChild(@NotNull org.apache.jackrabbit.oak.api.Tree parent,
@NotNull java.lang.String name,
@Nullable java.lang.String typeName,
@NotNull org.apache.jackrabbit.oak.api.Tree typeRoot,
@Nullable java.lang.String userID) |
static void |
addMixin(@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull java.lang.String mixinName,
@NotNull org.apache.jackrabbit.oak.api.Tree typeRoot,
@Nullable java.lang.String userID) |
static void |
autoCreateItems(@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull org.apache.jackrabbit.oak.api.Tree type,
@NotNull org.apache.jackrabbit.oak.api.Tree typeRoot,
@Nullable java.lang.String userID) |
static @Nullable org.apache.jackrabbit.oak.api.PropertyState |
autoCreateProperty(@NotNull java.lang.String name,
@NotNull org.apache.jackrabbit.oak.api.Tree definition,
@Nullable java.lang.String userID) |
static @Nullable java.lang.String |
findDefaultPrimaryType(@NotNull org.apache.jackrabbit.oak.api.Tree definitions,
boolean sns) |
static boolean |
getBoolean(@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull java.lang.String propertyName)
Returns the boolean representation of the property with the specified
propertyName. |
static @Nullable java.lang.String |
getDefaultChildType(@NotNull org.apache.jackrabbit.oak.api.Tree typeRoot,
@NotNull org.apache.jackrabbit.oak.api.Tree parent,
@NotNull java.lang.String childName)
Finds the default primary type for a new child node with the given name.
|
static @NotNull java.util.List<org.apache.jackrabbit.oak.api.Tree> |
getEffectiveType(@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull org.apache.jackrabbit.oak.api.Tree typeRoot)
Returns the effective node types of the given node.
|
static long |
getLong(@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull java.lang.String name,
long defaultValue) |
static @NotNull java.lang.Iterable<java.lang.String> |
getMixinTypeNames(@NotNull org.apache.jackrabbit.oak.api.Tree tree) |
static @NotNull java.lang.Iterable<java.lang.String> |
getMixinTypeNames(@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull org.apache.jackrabbit.oak.commons.LazyValue<org.apache.jackrabbit.oak.api.Tree> readOnlyTree) |
static @Nullable java.lang.String |
getName(@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull java.lang.String name) |
static @NotNull java.lang.Iterable<java.lang.String> |
getNames(@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull java.lang.String name) |
static @NotNull org.apache.jackrabbit.oak.api.Tree |
getOrAddChild(@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull java.lang.String childName,
@NotNull java.lang.String primaryTypeName)
Combination of
Tree.getChild(String) and adding a child including
its jcr:primaryType property (i.e. |
static @Nullable java.lang.String |
getPrimaryTypeName(@NotNull org.apache.jackrabbit.oak.api.Tree tree) |
static @Nullable java.lang.String |
getPrimaryTypeName(@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull org.apache.jackrabbit.oak.commons.LazyValue<org.apache.jackrabbit.oak.api.Tree> readOnlyTree) |
static @Nullable java.lang.String |
getString(@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull java.lang.String propertyName) |
static @Nullable java.lang.String |
getString(@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull java.lang.String name,
@Nullable java.lang.String defaultValue) |
static @Nullable java.lang.Iterable<java.lang.String> |
getStrings(@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull java.lang.String propertyName) |
static @Nullable org.apache.jackrabbit.oak.api.Tree |
getTree(@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull java.lang.String path)
Return the possibly non existing tree located at the passed
path from
the location of the start tree or null if path results
in a parent of the root. |
static boolean |
isNodeType(@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull java.lang.String typeName,
@NotNull org.apache.jackrabbit.oak.api.Tree typeRoot) |
static boolean |
isReadOnlyTree(@NotNull org.apache.jackrabbit.oak.api.Tree tree)
Returns
true if the specified tree is a read-only tree.. |
@Nullable
public static @Nullable java.lang.String getPrimaryTypeName(@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree tree)
@Nullable
public static @Nullable java.lang.String getPrimaryTypeName(@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull
@NotNull org.apache.jackrabbit.oak.commons.LazyValue<org.apache.jackrabbit.oak.api.Tree> readOnlyTree)
@NotNull
public static @NotNull java.lang.Iterable<java.lang.String> getMixinTypeNames(@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree tree)
@NotNull
public static @NotNull java.lang.Iterable<java.lang.String> getMixinTypeNames(@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull
@NotNull org.apache.jackrabbit.oak.commons.LazyValue<org.apache.jackrabbit.oak.api.Tree> readOnlyTree)
@Nullable
public static @Nullable java.lang.Iterable<java.lang.String> getStrings(@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull
@NotNull java.lang.String propertyName)
@Nullable
public static @Nullable java.lang.String getString(@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull
@NotNull java.lang.String propertyName)
@Nullable
public static @Nullable java.lang.String getString(@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull
@NotNull java.lang.String name,
@Nullable
@Nullable java.lang.String defaultValue)
public static boolean getBoolean(@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull
@NotNull java.lang.String propertyName)
propertyName. If the property does not exist or
is an array
this method returns false.tree - The target tree.propertyName - The name of the property.false if the property does not exist
or is an multivalued property.@Nullable
public static @Nullable java.lang.String getName(@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull
@NotNull java.lang.String name)
@NotNull
public static @NotNull java.lang.Iterable<java.lang.String> getNames(@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull
@NotNull java.lang.String name)
public static long getLong(@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull
@NotNull java.lang.String name,
long defaultValue)
@Nullable public static @Nullable org.apache.jackrabbit.oak.api.Tree getTree(@NotNull @NotNull org.apache.jackrabbit.oak.api.Tree tree, @NotNull @NotNull java.lang.String path)
path from
the location of the start tree or null if path results
in a parent of the root.tree - start treepath - path from the start treepath from start or null@NotNull public static @NotNull org.apache.jackrabbit.oak.api.Tree addChild(@NotNull @NotNull org.apache.jackrabbit.oak.api.Tree parent, @NotNull @NotNull java.lang.String name, @Nullable @Nullable java.lang.String typeName, @NotNull @NotNull org.apache.jackrabbit.oak.api.Tree typeRoot, @Nullable @Nullable java.lang.String userID) throws RepositoryException
RepositoryException@NotNull public static @NotNull org.apache.jackrabbit.oak.api.Tree addChild(@NotNull @NotNull org.apache.jackrabbit.oak.api.Tree tree, @NotNull @NotNull java.lang.String childName, @NotNull @NotNull java.lang.String primaryTypeName) throws AccessDeniedException
Tree.addChild(String) and
Tree.setProperty(String, Object, org.apache.jackrabbit.oak.api.Type)
where the property name is JcrConstants.JCR_PRIMARYTYPE.
Note, that this method in addition verifies if the created tree exists
and is accessible in order to avoid IllegalStateException upon
subsequent modification of the new child.childName - The Oak name of the child item.primaryTypeName - The Oak name of the primary node type.AccessDeniedException - If the child does not exist after creation.@NotNull public static @NotNull org.apache.jackrabbit.oak.api.Tree getOrAddChild(@NotNull @NotNull org.apache.jackrabbit.oak.api.Tree tree, @NotNull @NotNull java.lang.String childName, @NotNull @NotNull java.lang.String primaryTypeName) throws AccessDeniedException
Tree.getChild(String) and adding a child including
its jcr:primaryType property (i.e. Tree.addChild(String) and
Tree.setProperty(PropertyState)) in case no tree exists with the specified name.childName - The Oak name of the child item.primaryTypeName - The Oak name of the primary node type.AccessDeniedException - If the child does not exist after creation.public static void addMixin(@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull
@NotNull java.lang.String mixinName,
@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree typeRoot,
@Nullable
@Nullable java.lang.String userID)
throws RepositoryException
RepositoryExceptionpublic static void autoCreateItems(@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree type,
@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree typeRoot,
@Nullable
@Nullable java.lang.String userID)
throws RepositoryException
RepositoryException@Nullable public static @Nullable org.apache.jackrabbit.oak.api.PropertyState autoCreateProperty(@NotNull @NotNull java.lang.String name, @NotNull @NotNull org.apache.jackrabbit.oak.api.Tree definition, @Nullable @Nullable java.lang.String userID)
@Nullable
public static @Nullable java.lang.String getDefaultChildType(@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree typeRoot,
@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree parent,
@NotNull
@NotNull java.lang.String childName)
typeRoot - root of the /jcr:system/jcr:nodeTypes treeparent - parent nodechildName - name of the new child nodenull if not available@NotNull public static @NotNull java.util.List<org.apache.jackrabbit.oak.api.Tree> getEffectiveType(@NotNull @NotNull org.apache.jackrabbit.oak.api.Tree tree, @NotNull @NotNull org.apache.jackrabbit.oak.api.Tree typeRoot)
@Nullable
public static @Nullable java.lang.String findDefaultPrimaryType(@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree definitions,
boolean sns)
public static boolean isNodeType(@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree tree,
@NotNull
@NotNull java.lang.String typeName,
@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree typeRoot)
public static boolean isReadOnlyTree(@NotNull
@NotNull org.apache.jackrabbit.oak.api.Tree tree)
true if the specified tree is a read-only tree..tree - The tree object to be tested.true if the specified tree is an immutable read-only tree.ReadOnlyCopyright © 2012–2022 The Apache Software Foundation. All rights reserved.