@Override public void visit(Node node) throws RepositoryException { if (nodeMatches(node)) { operateOnNode(installContext, node); } } };
@Override protected Predicate getFilteringPredicate() { return predicate != null ? predicate : super.getFilteringPredicate(); }
@Override protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException { if (DEFAULT_ABS_PATH.equals(absPath)) { String query = String.format(SELECT_NODES_WITH_CERTAIN_VALUES, currentValue); NodeIterator nodeIterator = QueryUtil.search(workspaceName, query, Query.JCR_SQL2); while (nodeIterator.hasNext()) { Node node = nodeIterator.nextNode(); PropertyIterator iterator = node.getProperties(); while (iterator.hasNext()) { Property property = iterator.nextProperty(); if (property.getType() == PropertyType.STRING) { if (property.getString().equals(currentValue)) { property.setValue(newValue); } } } } } else { super.doExecute(installContext); } }
@Override protected void doExecute(final InstallContext installContext) throws RepositoryException, TaskExecutionException { // get node where we should start visiting Session session = installContext.getJCRSession(workspace); Node node = session.getNode(absPath); // visitor to help decoupling matching from operating logic NodeVisitor visitor = new NodeVisitor() { @Override public void visit(Node node) throws RepositoryException { if (nodeMatches(node)) { operateOnNode(installContext, node); } } }; // predicate defining where we should stop visiting the hierarchy Predicate predicate = getFilteringPredicate(); NodeUtil.visit(node, visitor, predicate); }