public class NodeUtil extends Object
Modifier and Type | Field and Description |
---|---|
static org.apache.jackrabbit.commons.predicate.Predicate |
ALL_NODES_EXCEPT_JCR_FILTER
Deprecated.
since 5.0 - obsolete as there's no nodetypes with namespace jcr
|
static AbstractPredicate<javax.jcr.Property> |
ALL_PROPERTIES_EXCEPT_JCR_AND_MGNL_FILTER
Deprecated.
since 5.0 - obsolete as there's no nodetypes with namespace jcr. In addition you could use
JCRMgnlPropertyHidingPredicate |
static AbstractPredicate<javax.jcr.Node> |
EXCLUDE_META_DATA_FILTER
Deprecated.
since 5.0 - obsolete as there's no nodetypes with namespace jcr and because of MAGNOLIA-4640
|
static AbstractPredicate<javax.jcr.Node> |
MAGNOLIA_FILTER
Node filter accepting all nodes of a type with namespace mgnl.
|
Constructor and Description |
---|
NodeUtil() |
Modifier and Type | Method and Description |
---|---|
static Iterable<javax.jcr.Node> |
asIterable(javax.jcr.NodeIterator iterator) |
static List<javax.jcr.Node> |
asList(Iterable<javax.jcr.Node> nodes) |
static Iterable<javax.jcr.Node> |
collectAllChildren(List<javax.jcr.Node> nodes,
javax.jcr.Node parent,
org.apache.jackrabbit.commons.predicate.Predicate predicate)
Get all children (by recursion) using a Predicate.
// TODO this method should really be private or renamed
|
static Iterable<javax.jcr.Node> |
collectAllChildren(javax.jcr.Node node)
Get all children (by recursion) using MAGNOLIA_FILTER (filter accepting all nodes of a type with namespace mgnl).
|
static Iterable<javax.jcr.Node> |
collectAllChildren(javax.jcr.Node node,
org.apache.jackrabbit.commons.predicate.Predicate predicate)
Get all children (by recursion) using a Predicate.
|
static String |
combinePathAndName(String path,
String name) |
static void |
copyInSession(javax.jcr.Node src,
String destAbsPath)
Session based copy operation.
|
static javax.jcr.Node |
createPath(javax.jcr.Node parent,
String relPath,
String primaryNodeTypeName)
Creates a node under the specified parent and relative path, then returns it.
|
static javax.jcr.Node |
createPath(javax.jcr.Node parent,
String relPath,
String primaryNodeTypeName,
boolean save)
Creates a node under the specified parent and relative path, then returns it.
|
static javax.jcr.Node |
deepUnwrap(javax.jcr.Node node,
Class<? extends DelegateNodeWrapper> wrapper)
Removes a wrapper by type.
|
static javax.jcr.Node |
deepUnwrapAll(javax.jcr.Node node,
Class<? extends DelegateNodeWrapper> wrapperClass)
Removes all wrappers of a given type.
|
static javax.jcr.NodeIterator |
filterDuplicates(javax.jcr.NodeIterator iterator) |
static javax.jcr.NodeIterator |
filterNodeType(javax.jcr.NodeIterator iterator,
String nodeType) |
static javax.jcr.NodeIterator |
filterParentNodeType(javax.jcr.NodeIterator iterator,
String nodeType) |
static javax.jcr.NodeIterator |
filterParentNodeType(javax.jcr.query.RowIterator iterator,
String selector)
Filters rows of result set from query by provided selector and returns such nodes in the NodeIterator.
|
static String |
getAbsolutePath(String path,
String label) |
static Collection<javax.jcr.Node> |
getAncestors(javax.jcr.Node node)
Get all Ancestors until level 1.
|
static Collection<javax.jcr.Node> |
getCollectionFromNodeIterator(javax.jcr.NodeIterator iterator) |
static String |
getName(javax.jcr.Node content)
This method return the node's name on success, otherwise it handles the
RepositoryException by throwing a RuntimeRepositoryException . |
static javax.jcr.Node |
getNearestAncestorOfType(javax.jcr.Node node,
String nodeTypeName)
Returns the nearest ancestor of a certain node type or null if none of the ancestors have the node type.
|
static javax.jcr.Node |
getNodeByIdentifier(String workspace,
String identifier)
Get a Node by identifier.
|
static String |
getNodeIdentifierIfPossible(javax.jcr.Node content)
Used for building exception messages where we want to avoid handling another exception inside a throws clause.
|
static String |
getNodePathIfPossible(javax.jcr.Node node) |
static Iterable<javax.jcr.Node> |
getNodes(javax.jcr.Node parent) |
static Iterable<javax.jcr.Node> |
getNodes(javax.jcr.Node parent,
org.apache.jackrabbit.commons.predicate.Predicate predicate) |
static Iterable<javax.jcr.Node> |
getNodes(javax.jcr.Node parent,
String nodeTypeName) |
static String |
getPathIfPossible(javax.jcr.Node node)
Return the Path of the node.
|
static javax.jcr.Node |
getSiblingAfter(javax.jcr.Node node) |
static javax.jcr.Node |
getSiblingBefore(javax.jcr.Node node) |
static Iterable<javax.jcr.Node> |
getSiblings(javax.jcr.Node node)
Gets the siblings of this node.
|
static Iterable<javax.jcr.Node> |
getSiblings(javax.jcr.Node node,
org.apache.jackrabbit.commons.predicate.Predicate predicate)
Gets the siblings of this node according to predicate.
|
static Iterable<javax.jcr.Node> |
getSiblings(javax.jcr.Node node,
String nodeTypeName)
Gets the siblings of this node with certain type.
|
static Iterable<javax.jcr.Node> |
getSiblingsAfter(javax.jcr.Node node)
Gets the siblings after this node.
|
static Iterable<javax.jcr.Node> |
getSiblingsAfter(javax.jcr.Node node,
String nodeTypeName)
Gets the siblings after this node with certain type.
|
static Iterable<javax.jcr.Node> |
getSiblingsBefore(javax.jcr.Node node)
Gets the siblings before this node.
|
static Iterable<javax.jcr.Node> |
getSiblingsBefore(javax.jcr.Node node,
String nodeTypeName)
Gets the siblings before this node with certain type.
|
static Collection<javax.jcr.Node> |
getSortedCollectionFromNodeIterator(javax.jcr.NodeIterator iterator)
Deprecated.
|
static boolean |
hasMixin(javax.jcr.Node node,
String mixinName)
Checks if the node has a mixin assigned.
|
static boolean |
isFirstSibling(javax.jcr.Node node) |
static boolean |
isGranted(javax.jcr.Node node,
long permissions) |
static boolean |
isLastSibling(javax.jcr.Node node) |
static boolean |
isNodeType(javax.jcr.Node node,
String nodeTypeName)
Checks if the node is of the supplied node type or if the node type is a mixin checks if the node has the mixin.
|
static boolean |
isSame(javax.jcr.Node lhs,
javax.jcr.Node rhs)
Returns true if both arguments represents the same node.
|
static boolean |
isSameNameSiblings(javax.jcr.Node node1,
javax.jcr.Node node2)
Check if node1 and node2 are siblings.
|
static boolean |
isWrappedWith(javax.jcr.Node node,
Class<? extends DelegateNodeWrapper> wrapper)
Check if node is wrapped by an instance of the given wrapper (subclasses of the wrapper are taken into account).
|
static void |
moveNode(javax.jcr.Node nodeToMove,
javax.jcr.Node newParent) |
static void |
moveNodeAfter(javax.jcr.Node nodeToMove,
javax.jcr.Node target) |
static void |
moveNodeBefore(javax.jcr.Node nodeToMove,
javax.jcr.Node target) |
static void |
moveProperty(javax.jcr.Property source,
javax.jcr.Node targetNode) |
static void |
orderAfter(javax.jcr.Node node,
String siblingName)
Orders the node directly after a given sibling.
|
static void |
orderBefore(javax.jcr.Node node,
String siblingName)
Convenience - delegate to
Node.orderBefore(String, String) . |
static void |
orderFirst(javax.jcr.Node node)
Orders the node first among its siblings.
|
static void |
orderLast(javax.jcr.Node node)
Orders the node last among its siblings.
|
static void |
orderNodeDown(javax.jcr.Node node)
Orders the node down one step among its siblings.
|
static void |
orderNodeUp(javax.jcr.Node node)
Orders the node up one step among its siblings.
|
static void |
renameNode(javax.jcr.Node node,
String newName) |
static javax.jcr.Node |
unwrap(javax.jcr.Node node) |
static void |
visit(javax.jcr.Node node,
NodeVisitor visitor)
Visits the given node and then all of nodes beneath it except for metadata nodes and nodes of jcr type.
|
static void |
visit(javax.jcr.Node node,
NodeVisitor visitor,
org.apache.jackrabbit.commons.predicate.Predicate predicate) |
@Deprecated public static AbstractPredicate<javax.jcr.Property> ALL_PROPERTIES_EXCEPT_JCR_AND_MGNL_FILTER
JCRMgnlPropertyHidingPredicate
@Deprecated public static org.apache.jackrabbit.commons.predicate.Predicate ALL_NODES_EXCEPT_JCR_FILTER
@Deprecated public static AbstractPredicate<javax.jcr.Node> EXCLUDE_META_DATA_FILTER
public static AbstractPredicate<javax.jcr.Node> MAGNOLIA_FILTER
public static javax.jcr.Node getNodeByIdentifier(String workspace, String identifier) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static boolean hasMixin(javax.jcr.Node node, String mixinName) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
Node.getMixinNodeTypes()
public static boolean isNodeType(javax.jcr.Node node, String nodeTypeName) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static javax.jcr.Node unwrap(javax.jcr.Node node) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static javax.jcr.Node deepUnwrap(javax.jcr.Node node, Class<? extends DelegateNodeWrapper> wrapper)
public static javax.jcr.Node deepUnwrapAll(javax.jcr.Node node, Class<? extends DelegateNodeWrapper> wrapperClass)
public static boolean isWrappedWith(javax.jcr.Node node, Class<? extends DelegateNodeWrapper> wrapper)
public static void orderBefore(javax.jcr.Node node, String siblingName) throws javax.jcr.RepositoryException
Node.orderBefore(String, String)
.javax.jcr.RepositoryException
public static void orderAfter(javax.jcr.Node node, String siblingName) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static void orderFirst(javax.jcr.Node node) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static void orderLast(javax.jcr.Node node) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static void orderNodeUp(javax.jcr.Node node) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static void orderNodeDown(javax.jcr.Node node) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static javax.jcr.Node getSiblingBefore(javax.jcr.Node node) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static javax.jcr.Node getSiblingAfter(javax.jcr.Node node) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static Iterable<javax.jcr.Node> getSiblings(javax.jcr.Node node) throws javax.jcr.RepositoryException
node
- node from which will be siblings retrievedjavax.jcr.RepositoryException
public static Iterable<javax.jcr.Node> getSiblings(javax.jcr.Node node, String nodeTypeName) throws javax.jcr.RepositoryException
node
- node from which will be siblings retrievednodeTypeName
- requested type of siblings nodesjavax.jcr.RepositoryException
public static Iterable<javax.jcr.Node> getSiblings(javax.jcr.Node node, org.apache.jackrabbit.commons.predicate.Predicate predicate) throws javax.jcr.RepositoryException
node
- node from which will be siblings retrievedpredicate
- predicatejavax.jcr.RepositoryException
public static Iterable<javax.jcr.Node> getSiblingsBefore(javax.jcr.Node node) throws javax.jcr.RepositoryException
node
- node from which will be siblings retrievedjavax.jcr.RepositoryException
public static Iterable<javax.jcr.Node> getSiblingsAfter(javax.jcr.Node node) throws javax.jcr.RepositoryException
node
- node from which will be siblings retrievedjavax.jcr.RepositoryException
public static Iterable<javax.jcr.Node> getSiblingsBefore(javax.jcr.Node node, String nodeTypeName) throws javax.jcr.RepositoryException
node
- node from which will be siblings retrievednodeTypeName
- requested type of siblings nodesjavax.jcr.RepositoryException
public static Iterable<javax.jcr.Node> getSiblingsAfter(javax.jcr.Node node, String nodeTypeName) throws javax.jcr.RepositoryException
node
- node from which will be siblings retrievednodeTypeName
- requested type of siblings nodesjavax.jcr.RepositoryException
public static void moveNode(javax.jcr.Node nodeToMove, javax.jcr.Node newParent) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static void moveNodeBefore(javax.jcr.Node nodeToMove, javax.jcr.Node target) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static void moveNodeAfter(javax.jcr.Node nodeToMove, javax.jcr.Node target) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static boolean isFirstSibling(javax.jcr.Node node) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static boolean isSameNameSiblings(javax.jcr.Node node1, javax.jcr.Node node2) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static boolean isLastSibling(javax.jcr.Node node) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static void renameNode(javax.jcr.Node node, String newName) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static boolean isGranted(javax.jcr.Node node, long permissions)
RuntimeRepositoryException
- in case of RepositoryException.public static boolean isSame(javax.jcr.Node lhs, javax.jcr.Node rhs) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static String combinePathAndName(String path, String name)
public static javax.jcr.Node createPath(javax.jcr.Node parent, String relPath, String primaryNodeTypeName) throws javax.jcr.RepositoryException, javax.jcr.PathNotFoundException, AccessDeniedException
javax.jcr.RepositoryException
javax.jcr.PathNotFoundException
AccessDeniedException
public static javax.jcr.Node createPath(javax.jcr.Node parent, String relPath, String primaryNodeTypeName, boolean save) throws javax.jcr.RepositoryException, javax.jcr.PathNotFoundException, AccessDeniedException
javax.jcr.RepositoryException
javax.jcr.PathNotFoundException
AccessDeniedException
public static void visit(javax.jcr.Node node, NodeVisitor visitor) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static void visit(javax.jcr.Node node, NodeVisitor visitor, org.apache.jackrabbit.commons.predicate.Predicate predicate) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static Iterable<javax.jcr.Node> getNodes(javax.jcr.Node parent, org.apache.jackrabbit.commons.predicate.Predicate predicate) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static Iterable<javax.jcr.Node> getNodes(javax.jcr.Node parent) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static Iterable<javax.jcr.Node> getNodes(javax.jcr.Node parent, String nodeTypeName) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static Iterable<javax.jcr.Node> asIterable(javax.jcr.NodeIterator iterator)
public static String getName(javax.jcr.Node content)
RepositoryException
by throwing a RuntimeRepositoryException
.public static Iterable<javax.jcr.Node> collectAllChildren(javax.jcr.Node node) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static Iterable<javax.jcr.Node> collectAllChildren(javax.jcr.Node node, org.apache.jackrabbit.commons.predicate.Predicate predicate) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static Iterable<javax.jcr.Node> collectAllChildren(List<javax.jcr.Node> nodes, javax.jcr.Node parent, org.apache.jackrabbit.commons.predicate.Predicate predicate) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static Collection<javax.jcr.Node> getAncestors(javax.jcr.Node node) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static javax.jcr.Node getNearestAncestorOfType(javax.jcr.Node node, String nodeTypeName) throws javax.jcr.RepositoryException
node
- the node whose ancestors to considernodeTypeName
- the node type to query forjavax.jcr.RepositoryException
public static String getNodeIdentifierIfPossible(javax.jcr.Node content)
public static String getNodePathIfPossible(javax.jcr.Node node)
public static String getPathIfPossible(javax.jcr.Node node)
public static javax.jcr.NodeIterator filterNodeType(javax.jcr.NodeIterator iterator, String nodeType)
public static javax.jcr.NodeIterator filterDuplicates(javax.jcr.NodeIterator iterator)
public static javax.jcr.NodeIterator filterParentNodeType(javax.jcr.NodeIterator iterator, String nodeType) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static javax.jcr.NodeIterator filterParentNodeType(javax.jcr.query.RowIterator iterator, String selector) throws javax.jcr.RepositoryException
iterator
- RowIterator from the result set of executed queryselector
- Selector used in the query to identify nodesjavax.jcr.RepositoryException
public static Collection<javax.jcr.Node> getCollectionFromNodeIterator(javax.jcr.NodeIterator iterator)
@Deprecated public static Collection<javax.jcr.Node> getSortedCollectionFromNodeIterator(javax.jcr.NodeIterator iterator)
public static void copyInSession(javax.jcr.Node src, String destAbsPath) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static void moveProperty(javax.jcr.Property source, javax.jcr.Node targetNode) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
Copyright © 2003–2018 Magnolia International Ltd.. All rights reserved.