public abstract class NodeVisitorTask extends AbstractRepositoryTask
NodeVisitorTask
helps traversing a repository, match nodes and execute changes on them.
This is intended to replace QueryTask
for most cases, since query results may not account for pending changes in the session (e.g. coming from earlier deltas).
DO_NOTHING, log
Constructor and Description |
---|
NodeVisitorTask(String name,
String description,
String workspace,
String absPath) |
Modifier and Type | Method and Description |
---|---|
protected void |
doExecute(InstallContext installContext) |
protected org.apache.jackrabbit.commons.predicate.Predicate |
getFilteringPredicate()
Override this method to specify a
Predicate where we should stop visiting the hierarchy, e.g. to restrict node-types. |
protected abstract boolean |
nodeMatches(javax.jcr.Node node)
Implement this method to define which nodes should subsequently be operated upon.
|
protected abstract void |
operateOnNode(InstallContext installContext,
javax.jcr.Node node)
Implement this method to apply changes to each of the nodes that are matched by
nodeMatches(Node) . |
execute
getDescription, getName, toString
protected void doExecute(InstallContext installContext) throws javax.jcr.RepositoryException, TaskExecutionException
doExecute
in class AbstractRepositoryTask
javax.jcr.RepositoryException
TaskExecutionException
protected abstract boolean nodeMatches(javax.jcr.Node node)
This will be called for every visited node in that task, and serves a similar purpose as a JCR query statement.
node
- the JCR node that is currently being visitedtrue
if the node should be operated upon, false
otherwiseoperateOnNode(InstallContext, Node)
protected abstract void operateOnNode(InstallContext installContext, javax.jcr.Node node)
nodeMatches(Node)
.
This is typically where the update logic goes, in a similar fashion as the QueryTask
.
installContext
- the current install contextnode
- the JCR node that should be operated uponQueryTask.operateOnNode(InstallContext, Node)
protected org.apache.jackrabbit.commons.predicate.Predicate getFilteringPredicate()
Predicate
where we should stop visiting the hierarchy, e.g. to restrict node-types.
Mind that whatever the predicate, the starting node is always visited by NodeUtil
, even if it doesn't match the predicate.
true
for all objects.Copyright © 2003–2018 Magnolia International Ltd.. All rights reserved.