use of javax.jcr.NodeIterator in project jackrabbit by apache.
the class XATransaction method execute.
public NodeIterator execute() throws Exception {
UserTransactionImpl tx = new UserTransactionImpl(getSession());
log.info("begin transaction");
tx.begin();
NodeIterator it = op.execute();
log.info("commit transaction");
tx.commit();
return it;
}
use of javax.jcr.NodeIterator in project jackrabbit by apache.
the class LargeResultSetTest method tearDown.
protected void tearDown() throws Exception {
int count = 0;
for (NodeIterator it = testRootNode.getNodes(); it.hasNext(); ) {
it.nextNode().remove();
count++;
if (count % 10000 == 0) {
session.save();
}
}
session.save();
super.tearDown();
}
use of javax.jcr.NodeIterator in project jackrabbit by apache.
the class Exporter method exportNodes.
/**
* Called by {@link #exportNode(String, String, Node)} to recursively
* call {@link #exportNode(String, String, Node)} for each child node.
* Does nothing if this exporter is not recursive.
*
* @param node parent node
* @throws RepositoryException if a repository error occurs
* @throws SAXException if a SAX error occurs
*/
protected void exportNodes(Node node) throws RepositoryException, SAXException {
if (recurse && !share) {
NodeIterator iterator = node.getNodes();
while (iterator.hasNext()) {
Node child = iterator.nextNode();
exportNode(child);
}
}
}
use of javax.jcr.NodeIterator in project jackrabbit by apache.
the class FilteringItemVisitor method visit.
/**
* Called when the Visitor is passed to a <code>Node</code>.
* <p>
* It calls <code>TraversingItemVisitor.entering(Node, int)</code> followed by
* <code>TraversingItemVisitor.leaving(Node, int)</code>. Implement these abstract methods to
* specify behaviour on 'arrival at' and 'after leaving' the <code>Node</code>.
* <p>
* If this method throws, the visiting process is aborted.
*
* @param node the <code>Node</code> that is accepting this visitor.
* @throws RepositoryException if an error occurrs
*/
public void visit(Node node) throws RepositoryException {
if (this.traversalPredicate.evaluate(node)) {
if (this.includePredicate == this.traversalPredicate || this.includePredicate.evaluate(node)) {
try {
if (!breadthFirst) {
// depth-first traversal
entering(node, currentLevel);
if (maxLevel == -1 || currentLevel < maxLevel) {
currentLevel++;
if (this.walkProperties) {
PropertyIterator propIter = node.getProperties();
while (propIter.hasNext()) {
propIter.nextProperty().accept(this);
}
}
NodeIterator nodeIter = node.getNodes();
while (nodeIter.hasNext()) {
nodeIter.nextNode().accept(this);
}
currentLevel--;
}
leaving(node, currentLevel);
} else {
// breadth-first traversal
entering(node, currentLevel);
leaving(node, currentLevel);
if (maxLevel == -1 || currentLevel < maxLevel) {
if (this.walkProperties) {
PropertyIterator propIter = node.getProperties();
while (propIter.hasNext()) {
nextQueue.addLast(propIter.nextProperty());
}
}
NodeIterator nodeIter = node.getNodes();
while (nodeIter.hasNext()) {
nextQueue.addLast(nodeIter.nextNode());
}
}
while (!currentQueue.isEmpty() || !nextQueue.isEmpty()) {
if (currentQueue.isEmpty()) {
currentLevel++;
currentQueue = nextQueue;
nextQueue = new LinkedList();
}
Item e = (Item) currentQueue.removeFirst();
e.accept(this);
}
currentLevel = 0;
}
} catch (RepositoryException re) {
currentLevel = 0;
throw re;
}
}
}
}
use of javax.jcr.NodeIterator in project jackrabbit by apache.
the class ShareableNodeTest method testSearch.
/**
* Verify that a descendant of a shareable node appears once in the
* result set (6.13.23)
*/
public void testSearch() throws Exception {
// setup parent nodes and first child
Node a1 = testRootNode.addNode("a1");
Node a2 = testRootNode.addNode("a2");
Node b1 = a1.addNode("b1");
testRootNode.getSession().save();
// add mixin
ensureMixinType(b1, mixShareable);
b1.save();
// clone
Workspace workspace = b1.getSession().getWorkspace();
workspace.clone(workspace.getName(), b1.getPath(), a2.getPath() + "/b2", false);
// add new referenceable child
Node c = b1.addNode("c");
ensureMixinType(c, mixReferenceable);
b1.save();
String sql = "SELECT * FROM nt:unstructured WHERE jcr:uuid = '" + c.getUUID() + "'";
QueryResult res = workspace.getQueryManager().createQuery(sql, Query.SQL).execute();
List<Node> list = new ArrayList<Node>();
NodeIterator iter = res.getNodes();
while (iter.hasNext()) {
list.add(iter.nextNode());
}
assertEquals(1, list.size());
assertTrue(list.get(0).isSame(c));
}
Aggregations